https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108434
--- Comment #7 from anlauf at gcc dot gnu.org --- (In reply to anlauf from comment #6) > There is another potential issue (see comment#1) which might be related > to this one or not. Keeping this PR open until the finalization work > reaches the next stage... The variant from comment#1 first hits a NULL pointer dereference fixed by: diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc index bffc0ffff3a..0436db82020 100644 --- a/gcc/fortran/class.cc +++ b/gcc/fortran/class.cc @@ -940,7 +940,7 @@ comp_is_finalizable (gfc_component *comp) || (comp->ts.u.derived->f2k_derived && comp->ts.u.derived->f2k_derived->finalizers))) return true; - else if (comp->ts.type == BT_CLASS && CLASS_DATA (comp) + else if (comp->ts.type == BT_CLASS && comp->attr.class_ok && CLASS_DATA (comp) && CLASS_DATA (comp)->attr.allocatable) return true; else but afterwards generates a traceback in generate_finalization_wrapper: pr108434-aa.f90:8:35: 8 | class(c), allocatable :: a(2) ! { dg-error "must have a deferred shape" } | 1 Error: Allocatable component of structure at (1) must have a deferred shape f951: internal compiler error: in generate_finalization_wrapper, at fortran/class.cc:1714 0x8e10e1 generate_finalization_wrapper ../../gcc-trunk/gcc/fortran/class.cc:1714 0x8e4396 gfc_find_derived_vtab(gfc_symbol*) ../../gcc-trunk/gcc/fortran/class.cc:2618 0x9abfb8 resolve_fl_derived ../../gcc-trunk/gcc/fortran/resolve.cc:15482 0x9ad0af resolve_symbol ../../gcc-trunk/gcc/fortran/resolve.cc:15867 0x9d78d8 do_traverse_symtree ../../gcc-trunk/gcc/fortran/symbol.cc:4196 0x9d7996 gfc_traverse_ns(gfc_namespace*, void (*)(gfc_symbol*)) ../../gcc-trunk/gcc/fortran/symbol.cc:4221 0x9b1f95 resolve_types ../../gcc-trunk/gcc/fortran/resolve.cc:17830 0x9b2446 gfc_resolve(gfc_namespace*) ../../gcc-trunk/gcc/fortran/resolve.cc:17945 0x97f916 resolve_all_program_units ../../gcc-trunk/gcc/fortran/parse.cc:6655 0x980112 gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.cc:6911 0x9e779f gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.cc:229