http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50408
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-24 22:20:55 UTC --- Patch for this issue - note that there are more places which have to be checked and potentially fixed. The second part is just a performance/algorithmic optimization, which occurs in real code. --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1671,6 +1671,9 @@ gfc_get_extern_function_decl (gfc_symbol * sym) if (s && s->backend_decl) { sym->backend_decl = s->backend_decl; + if ((sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS) + && sym->ts.u.derived->backend_decl == NULL) + gfc_get_derived_type (sym->ts.u.derived); return sym->backend_decl; } } --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2188,6 +2188,9 @@ gfc_copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to, gfc_component *to_cm; gfc_component *from_cm; + if (from == to) + return 1; + if (from->backend_decl == NULL || !gfc_compare_derived_types (from, to)) return 0;