https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #1) > Instead of an assert(), simply return false to give gfortran a chance to > emit an error. Steve, your patch does fix z1, but not z2, which hits the gfc_internal_error ("gfc_array_size failed"); a few lines later... The following adjusted patch fixes the latter, too, regtests cleanly, and gives nicer error messages :) diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 339f8b15035..b6400514731 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2129,10 +2129,21 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_ locus) /* The shape may be NULL for EXPR_ARRAY, set it. */ if (init->shape == NULL) { - gcc_assert (init->expr_type == EXPR_ARRAY); + if (init->expr_type != EXPR_ARRAY) + { + gfc_error ("Bad shape of initializer at %L", &init->where); + return false; + } + init->shape = gfc_get_shape (1); if (!gfc_array_size (init, &init->shape[0])) - gfc_internal_error ("gfc_array_size failed"); + { + gfc_error ("Cannot determine shape of initializer at %L", + &init->where); + free (init->shape); + init->shape = NULL; + return false; + } } for (dim = 0; dim < sym->as->rank; ++dim)