https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104311
--- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to anlauf from comment #2) > We could limit the size of the resulting array constructor, using e.g. > flag_max_array_constructor. Sample patch: diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 6483f9c31e7..15a2b36eed9 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -8152,6 +8152,15 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size) if (source->expr_type == EXPR_ARRAY && !gfc_array_size (source, &tmp)) gfc_internal_error ("Failure getting length of a constant array."); + if (size && mpz_cmp_si (size->value.integer, flag_max_array_constructor) > 0) + { + gfc_error ("The number of elements in the array constructor " + "at %L requires an increase of the allowed %d " + "upper limit. See %<-fmax-array-constructor%> " + "option", &size->where, flag_max_array_constructor); + return NULL; + } + /* Create an empty new expression with the appropriate characteristics. */ result = gfc_get_constant_expr (mold->ts.type, mold->ts.kind, &source->where);