aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2007-03-03 17:37:54 +0100
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-03-03 16:37:54 +0000
commit42d53ef301752ba26a6e2d76929a8085a00c0d18 (patch)
tree9602966aa875abbb82cf2f175ed23ea17e0a1d0d /libgfortran
parent4e09692de3922d40138146608367dfbd0ac15c97 (diff)
downloadgcc-42d53ef301752ba26a6e2d76929a8085a00c0d18.zip
gcc-42d53ef301752ba26a6e2d76929a8085a00c0d18.tar.gz
gcc-42d53ef301752ba26a6e2d76929a8085a00c0d18.tar.bz2
re PR libfortran/31001 ([4.1 only] PACK crashes on zero-sized arrays)
PR libfortran/31001 * intrinsics/pack_generic.c (pack_internal): Add special checks for zero-sized arrays. * gfortran.dg/zero_sized_3.f90: New test. From-SVN: r122507
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/intrinsics/pack_generic.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 49ab4dd..cfa42b2 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-03 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ PR libfortran/31001
+ * intrinsics/pack_generic.c (pack_internal): Add special checks
+ for zero-sized arrays.
+
2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
* Makefile.am: Add dummy install-pdf target.
diff --git a/libgfortran/intrinsics/pack_generic.c b/libgfortran/intrinsics/pack_generic.c
index 1b0d725..06e7084 100644
--- a/libgfortran/intrinsics/pack_generic.c
+++ b/libgfortran/intrinsics/pack_generic.c
@@ -93,15 +93,19 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array,
index_type count[GFC_MAX_DIMENSIONS];
index_type extent[GFC_MAX_DIMENSIONS];
+ int zero_sized;
index_type n;
index_type dim;
index_type nelem;
dim = GFC_DESCRIPTOR_RANK (array);
+ zero_sized = 0;
for (n = 0; n < dim; n++)
{
count[n] = 0;
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ if (extent[n] <= 0)
+ zero_sized = 1;
sstride[n] = array->dim[n].stride * size;
mstride[n] = mask->dim[n].stride;
}
@@ -154,6 +158,8 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array,
const GFC_LOGICAL_4 *m = mptr;
total = 0;
+ if (zero_sized)
+ m = NULL;
while (m)
{