summaryrefslogtreecommitdiff
path: root/libgfortran/m4/reshape.m4
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/m4/reshape.m4')
-rw-r--r--libgfortran/m4/reshape.m49
1 files changed, 8 insertions, 1 deletions
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index b7e321e3bb4..aa5d42960f7 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -139,7 +139,14 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
(long int) ret_extent, (long int) shape_data[n]);
}
- source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
+ source_extent = 1;
+ sdim = GFC_DESCRIPTOR_RANK (source);
+ for (n = 0; n < sdim; n++)
+ {
+ index_type se;
+ se = source->dim[n].ubound + 1 - source->dim[0].lbound;
+ source_extent *= se > 0 ? se : 0;
+ }
if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"