public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/24590]  New: Static function named "main" treated as the real main
@ 2005-10-31  6:29 mmitchel at gcc dot gnu dot org
  2005-10-31  6:29 ` [Bug middle-end/24590] " mmitchel at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-31  6:29 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-08 21:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24590-4@http.gcc.gnu.org/bugzilla/>
2021-08-08 21:30 ` [Bug middle-end/24590] Static function named "main" treated as the real main pinskia at gcc dot gnu.org
2005-10-31  6:29 [Bug middle-end/24590] New: " mmitchel at gcc dot gnu dot org
2005-10-31  6:29 ` [Bug middle-end/24590] " mmitchel at gcc dot gnu dot org
2005-10-31 15:45 ` pinskia at gcc dot gnu dot org
2006-01-29 17:49 ` pinskia at gcc dot gnu dot org
2006-01-29 17:50 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).