http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49648
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-07-05 19:46:45 UTC --- Draft patch, which should also save some memory, .mod file-size and should slightly speed the program. It fixes the test case in comment 0 and comment 2, but I have not yet regtested it (currently bootstrapping). A modification would be to not write it at all - and simply add "sym->result = sym" if sym->attr.function. (This will break .mod compatibility, which was last done 2011-03-29 - though I am not 100% sure that 4.6 and 4.7 are indeed still compatible.) --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -3631,7 +3637,10 @@ mio_symbol (gfc_symbol *sym) mio_array_spec (&sym->as); - mio_symbol_ref (&sym->result); + if (iomode == IO_OUTPUT && sym->result != sym) + mio_symbol_ref (&sym); + else + mio_symbol_ref (&sym->result); if (sym->attr.cray_pointee) mio_symbol_ref (&sym->cp_pointer);