https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61819
Dominique d'Humieres <dominiq at lps dot ens.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |damian at sourceryinstitute dot or | |g --- Comment #10 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- > Likely r206379 (pr59589). If I partially revert r206379, the ICEs for pr54784, pr59765, pr60529, pr61766, pr61819, and pr61822 are gone. Indeed the memory leak for pr59589 reappears and I get an ICE at trans-array.c:146 for the test in comment 1 of pr56385 (gfortran.dg/proc_ptr_comp_37.f90), but not in the original test. --- ../_clean/gcc/fortran/class.c 2014-05-07 12:46:43.000000000 +0200 +++ gcc/fortran/class.c 2014-07-17 18:01:17.000000000 +0200 @@ -833,7 +833,20 @@ finalize_component (gfc_expr *expr, gfc_ gfc_expr *e; gfc_ref *ref; - if (!comp_is_finalizable (comp)) +/* if (!comp_is_finalizable (comp)) */ + if (comp->ts.type != BT_DERIVED && comp->ts.type != BT_CLASS + && !comp->attr.allocatable) + return; + + if ((comp->ts.type == BT_DERIVED && comp->attr.pointer) + || (comp->ts.type == BT_CLASS && CLASS_DATA (comp) + && CLASS_DATA (comp)->attr.pointer)) + return; + + if (comp->ts.type == BT_DERIVED && !comp->attr.allocatable + && (comp->ts.u.derived->f2k_derived == NULL + || comp->ts.u.derived->f2k_derived->finalizers == NULL) + && !has_finalizer_component (comp->ts.u.derived)) return; e = gfc_copy_expr (expr); Note the ICEs reappear if I apply on top of the above the patch in comment 13 of pr59589. Could people familiar with finalization compare the tests in the above PRs and try to infer why comp->ts.u.derived->attr.alloc_comp changes the compiler behavior.