This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/24590] New: Static function named "main" treated as the real main
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Oct 2005 06:29:17 -0000
- Subject: [Bug middle-end/24590] New: Static function named "main" treated as the real main
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In tree_expand_cfg, we have:
if (DECL_NAME (current_function_decl)
&& MAIN_NAME_P (DECL_NAME (current_function_decl))
&& DECL_FILE_SCOPE_P (current_function_decl))
expand_main_function ();
This code should also check TREE_PUBLIC (c_f_d) (and the entire predicate
should probably be encapsulated in a macro or function).
Compiling this test case:
extern void f();
static int main () {
f();
}
int g() {
f();
}
on x86_64-unknown-linux-gnu with -m32 shows that the usual stack-alignment and
implicit return of zero code is generated for this "main" function, even though
it's not the real main function.
--
Summary: Static function named "main" treated as the real main
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mmitchel at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24590