------- Comment #6 from dave dot korn dot cygwin at gmail dot com 2009-05-30 16:12 ------- Groan.
PASS: gfortran.dg/Wall.f90 (test for excess errors) spawn [open ...] Internal Error: insert(): Duplicate key found! FAIL: gfortran.dg/Wall.f90 execution test In other words, exactly what Andrew warned would happen. Breakpoint 1, __main () at /gnu/winsup/src/winsup/cygwin/dcrt0.cc:993 993 do_global_ctors (user_data->ctors, false); (gdb) bt #0 __main () at /gnu/winsup/src/winsup/cygwin/dcrt0.cc:993 #1 0x00401166 in main () (gdb) c Continuing. Breakpoint 1, __main () at /gnu/winsup/src/winsup/cygwin/dcrt0.cc:993 993 do_global_ctors (user_data->ctors, false); (gdb) bt #0 __main () at /gnu/winsup/src/winsup/cygwin/dcrt0.cc:993 #1 0x004010ee in MAIN__ () #2 0x00401191 in main () (gdb) For some reason though, there isn't any call to __main in MAIN__ in my original "hello world" testcase, only in main. I don't yet understand that. It may be to do with the usage of main_program_symbol() in parse.c, which is called from two places: case ST_PROGRAM: if (seen_program) goto duplicate_main; seen_program = 1; prog_locus = gfc_current_locus; push_state (&s, COMP_PROGRAM, gfc_new_block); main_program_symbol(gfc_current_ns, gfc_new_block->name); accept_statement (st); /* Anything else starts a nameless main program block. */ default: if (seen_program) goto duplicate_main; seen_program = 1; prog_locus = gfc_current_locus; push_state (&s, COMP_PROGRAM, gfc_new_block); main_program_symbol (gfc_current_ns, "MAIN__"); I'm not sure yet what happens when we take the first one of these clauses and create a main function that is not called "MAIN__", because there is code in gfc_sym_mangled_function_id in trans-decl.c that assumes any main function has the same name: /* Main program is mangled into MAIN__. */ if (sym->attr.is_main_program) return get_identifier ("MAIN__"); Possibly this is an inconsistency, and if there's a named main block we create a main function but then look up what will effectively be an unrelated name. I need advice from someone who knows the fortran compiler internals better than me. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40309