https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88357
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to G. Steinmetz from comment #0) > With invalid code, down to at least gcc-5 : > > > $ cat z1.f90 > program p > type t > end type > class(t) :: x[*] > associate (y => x) > end associate > end > > > $ gfortran-9-20181202 -c z1.f90 -fcoarray=single > f951: internal compiler error: Segmentation fault > 0xc8f33f crash_signal > ../../gcc/toplev.c:326 > 0x69b4b9 parse_associate > ../../gcc/fortran/parse.c:4568 Index: gcc/fortran/parse.c =================================================================== --- gcc/fortran/parse.c (revision 266766) +++ gcc/fortran/parse.c (working copy) @@ -4563,7 +4563,7 @@ parse_associate (void) else rank = a->target->rank; /* When the rank is greater than zero then sym will be an array. */ - if (sym->ts.type == BT_CLASS) + if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)) { if ((!CLASS_DATA (sym)->as && rank != 0) || (CLASS_DATA (sym)->as Index: gcc/fortran/class.c =================================================================== --- gcc/fortran/class.c (revision 266766) +++ gcc/fortran/class.c (working copy) @@ -72,14 +72,18 @@ along with GCC; see the file COPYING3. If not see static void insert_component_ref (gfc_typespec *ts, gfc_ref **ref, const char * const name) { - gfc_symbol *type_sym; gfc_ref *new_ref; + int wcnt, ecnt; gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS); - type_sym = ts->u.derived; - gfc_find_component (type_sym, name, true, true, &new_ref); + gfc_find_component (ts->u.derived, name, true, true, &new_ref); + + gfc_get_errors (&wcnt, &ecnt); + if (ecnt > 0 && !new_ref) + return; gcc_assert (new_ref->u.c.component); + while (new_ref->next) new_ref = new_ref->next; new_ref->next = *ref;