This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/40309] New: gfortran does not support static c/d-tors.
- From: "dave dot korn dot cygwin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 May 2009 14:52:56 -0000
- Subject: [Bug fortran/40309] New: gfortran does not support static c/d-tors.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[ 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