https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59107
--- Comment #11 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- Updated patch for 5.0 --- ../_clean/gcc/fortran/gfortran.h 2015-01-19 02:01:40.000000000 +0100 +++ gcc/fortran/gfortran.h 2015-01-22 11:42:56.000000000 +0100 @@ -1451,7 +1451,7 @@ typedef struct gfc_symbol /* Set if this variable is used as an index name in a FORALL. */ unsigned forall_index:1; /* Used to avoid multiple resolutions of a single symbol. */ - unsigned resolved:1; + unsigned resolve_symbol_called:2; int refs; struct gfc_namespace *ns; /* namespace containing this symbol */ --- ../_clean/gcc/fortran/resolve.c 2015-01-18 17:58:11.000000000 +0100 +++ gcc/fortran/resolve.c 2015-01-22 11:41:38.000000000 +0100 @@ -1625,8 +1625,9 @@ gfc_resolve_intrinsic (gfc_symbol *sym, gfc_intrinsic_sym* isym = NULL; const char* symstd; - if (sym->formal) + if (sym->resolve_symbol_called >= 2) return true; + sym->resolve_symbol_called = 2; /* Already resolved. */ if (sym->from_intmod && sym->ts.type != BT_UNKNOWN) @@ -6930,7 +6931,9 @@ resolve_allocate_expr (gfc_expr *e, gfc_ goto failure; } - if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred) + /* Check F08:C632. */ + if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred + && !UNLIMITED_POLY (e)) { int cmp = gfc_dep_compare_expr (e->ts.u.cl->length, code->ext.alloc.ts.u.cl->length); @@ -13082,9 +13085,9 @@ resolve_symbol (gfc_symbol *sym) gfc_array_spec *as; bool saved_specification_expr; - if (sym->resolved) + if (sym->resolve_symbol_called >= 1) return; - sym->resolved = 1; + sym->resolve_symbol_called = 1; if (sym->attr.artificial) return; It regtest cleanly. If it helps, I can take this PR.