public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40309]  New: gfortran does not support static c/d-tors.
@ 2009-05-30 14:53 dave dot korn dot cygwin at gmail dot com
  2009-05-30 15:01 ` [Bug fortran/40309] " dave dot korn dot cygwin at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dave dot korn dot cygwin at gmail dot com @ 2009-05-30 14:53 UTC (permalink / raw)
  To: gcc-bugs

[ ref: http://gcc.gnu.org/onlinedocs/gccint/Initialization.html ]
[ ref: http://gcc.gnu.org/ml/fortran/2009-05/threads.html#00440 ]

gfortran does not set main_identifier_node to anything.  This causes
gimple_expand_cfg() in cfgexpand.c to fail to emit a call to the libgcc static
init function __main, because the MAIN_NAME_P check in this conditional:

  /* If this function is `main', emit a call to `__main'
     to run global initializers, etc.  */
  if (DECL_NAME (current_function_decl)
      && MAIN_NAME_P (DECL_NAME (current_function_decl))
      && DECL_FILE_SCOPE_P (current_function_decl))
    expand_main_function ();

fails.  On cygwin, this means that gfortran's init() function is never set up,
the units and option variables don't get initialised, and "hello world" fails
when it tries to output the first char, with a runtime library error.

The fix is to correctly initialise it somewhere in the fortran compiler's early
 startup, using a line as simple as:

  main_identifier_node = get_identifier ("main");

although I don't know for sure what mangled version of the name "main" to use
for fortran, or where would be the best place in the fortran frontend to put
this code.


-- 
           Summary: gfortran does not support static c/d-tors.
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dave dot korn dot cygwin at gmail dot com
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40309


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

end of thread, other threads:[~2009-06-01  8:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-30 14:53 [Bug fortran/40309] New: gfortran does not support static c/d-tors dave dot korn dot cygwin at gmail dot com
2009-05-30 15:01 ` [Bug fortran/40309] " dave dot korn dot cygwin at gmail dot com
2009-05-30 15:11 ` pinskia at gcc dot gnu dot org
2009-05-30 15:19 ` dave dot korn dot cygwin at gmail dot com
2009-05-30 15:34 ` dave dot korn dot cygwin at gmail dot com
2009-05-30 15:38 ` dave dot korn dot cygwin at gmail dot com
2009-05-30 16:13 ` dave dot korn dot cygwin at gmail dot com
2009-05-30 17:09 ` dave dot korn dot cygwin at gmail dot com
2009-05-30 21:15 ` burnus at gcc dot gnu dot org
2009-06-01  7:01 ` burnus at gcc dot gnu dot org
2009-06-01  7:34 ` burnus at gcc dot gnu dot org
2009-06-01  8:05 ` dave dot korn dot cygwin at gmail dot com

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).