[Bug libfortran/27895] problem with SPREAD and zero-sized arrays

fxcoudert at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Jun 5 13:46:00 GMT 2006



------- 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



More information about the Gcc-bugs mailing list