https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79956
--- Comment #20 from Markus Trippelsdorf <trippels at gcc dot gnu.org> --- The following fixes the warning for me: diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4 index 787844ec42d..42379d58a29 100644 --- a/libgfortran/m4/reshape.m4 +++ b/libgfortran/m4/reshape.m4 @@ -236,6 +236,10 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret, } sdim = GFC_DESCRIPTOR_RANK (source); + + if (!sdim) + return; + ssize = 1; sempty = 0; for (n = 0; n < sdim; n++)