https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120431
--- Comment #2 from kargls at comcast dot net --- The following diff "fixes" the problem. Or, I should say it would fix the problem if I could regenerate the c files from the m4 file. For whatever reason, --enable-maintainer-mode no longer regenerates files. diff --git a/libgfortran/m4/spread.m4 b/libgfortran/m4/spread.m4 index 67f4261f3c8..452e87da1ae 100644 --- a/libgfortran/m4/spread.m4 +++ b/libgfortran/m4/spread.m4 @@ -234,7 +234,7 @@ spread_scalar_'rtype_code` ('rtype` *ret, const 'rtype_name` *source, const index_type along, const index_type ncopies) { 'rtype_name` * restrict dest; - index_type stride; + index_type stride, nmax; if (GFC_DESCRIPTOR_RANK (ret) != 1) runtime_error ("incorrect destination rank in spread()"); @@ -244,7 +244,8 @@ spread_scalar_'rtype_code` ('rtype` *ret, const 'rtype_name` *source, if (ret->base_addr == NULL) { - ret->base_addr = xmallocarray (ncopies, sizeof ('rtype_name`)); + nmax = ncopies > 0 ? ncopies : 0; + ret->base_addr = xmallocarray (nmax, sizeof ('rtype_name`)); ret->offset = 0; GFC_DIMENSION_SET(ret->dim[0], 0, ncopies - 1, 1); }