https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96624
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2020-08-15 Status|UNCONFIRMED |NEW Priority|P3 |P4 --- Comment #1 from kargl at gcc dot gnu.org --- Why? Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (revision 280157) +++ gcc/fortran/simplify.c (working copy) @@ -6650,6 +6650,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shap unsigned long j; size_t nsource; gfc_expr *e, *result; + bool zerosize = false; /* Check that argument expression types are OK. */ if (!is_constant_array_expr (source) @@ -6772,8 +6773,15 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shap result->rank = rank; result->shape = gfc_get_shape (rank); for (i = 0; i < rank; i++) - mpz_init_set_ui (result->shape[i], shape[i]); + { + mpz_init_set_ui (result->shape[i], shape[i]); + if (shape[i] == 0) + zerosize = true; + } + if (zerosize) + goto sizezero; + while (nsource > 0 || npad > 0) { /* Figure out which element to extract. */ @@ -6821,6 +6829,8 @@ inc: break; } + +sizezero: mpz_clear (index);