This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/27895] problem with SPREAD and zero-sized arrays
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jun 2006 13:46:09 -0000
- Subject: [Bug libfortran/27895] problem with SPREAD and zero-sized arrays
- References: <bug-27895-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2006-06-05 13:46 -------
I believe the segfault is appropriately fixed by the following patch:
Index: libgfortran/intrinsics/spread_generic.c
===================================================================
--- libgfortran/intrinsics/spread_generic.c (revision 114340)
+++ libgfortran/intrinsics/spread_generic.c (working copy)
@@ -101,7 +101,14 @@
}
}
ret->offset = 0;
- ret->data = internal_malloc_size (rs * size);
+ if (rs * size == 0)
+ {
+ ret->data = internal_malloc_size (1);
+ ret->data[0] = 0;
+ return;
+ }
+ else
+ ret->data = internal_malloc_size (rs * size);
}
else
{
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27895