[Bug libfortran/31001] PACK crashes on zero-sized arrays
fxcoudert at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Mar 3 14:24:00 GMT 2007
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2007-03-03 14:24 -------
Patch below, currently regtesting.
Index: libgfortran/intrinsics/pack_generic.c
===================================================================
--- libgfortran/intrinsics/pack_generic.c (revision 122504)
+++ libgfortran/intrinsics/pack_generic.c (working copy)
@@ -93,15 +93,19 @@
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 @@
const GFC_LOGICAL_4 *m = mptr;
total = 0;
+ if (zero_sized)
+ m = NULL;
while (m)
{
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
GCC host triplet|i686-pc-linux-gnu |
Keywords| |patch, wrong-code
Known to fail| |4.1.2 4.2.0 4.3.0
Last reconfirmed|2007-03-03 10:38:13 |2007-03-03 14:24:04
date| |
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31001
More information about the Gcc-bugs
mailing list