https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110987
--- Comment #3 from Kirill Chilikin <chilikin.k at gmail dot com> --- The derived type T3 has zero components but not zero length as it extends T1; the test does not crash after the following changes: diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 961b0b5a573..e5d12f25e5e 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1624,7 +1624,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *derived, } else if (derived && gfc_is_finalizable (derived, NULL)) { - if (derived->attr.zero_comp && !rank) + if ((derived->components == NULL) && !rank) { /* Any attempt to assign zero length entities, causes the gimplifier all manner of problems. Instead, a variable is created to act as @@ -1685,7 +1685,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *derived, } } - if (derived && derived->attr.zero_comp) + if (derived && (derived->components == NULL)) { /* All the conditions below break down for zero length derived types. */ tmp = build_call_expr_loc (input_location, final_fndecl, 3,