re PR fortran/35991 (run-time abort for CSHIFT of zero sized array)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sun, 20 Apr 2008 21:06:16 +0000 (21:06 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sun, 20 Apr 2008 21:06:16 +0000 (21:06 +0000)
2008-04-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/35991
* intrinsics/cshift0.c (cshift0): Avoid divide by zero.

From-SVN: r134491

libgfortran/ChangeLog
libgfortran/intrinsics/cshift0.c

index 922eef795d25a8b3bc2efab291dfba6f78f4e01c..8ef3e0fc55e57ffa918a63bfde4e187ae297fe15 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/35991
+       * intrinsics/cshift0.c (cshift0): Avoid divide by zero.
+
 2008-04-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR libfortran/35960
index 75762a8158fe085b7d3f90c3dccf4e20384cecf1..aa466ff3b6bdcc260870e64ca8c97788dda52af2 100644 (file)
@@ -202,7 +202,7 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
   rptr = ret->data;
   sptr = array->data;
 
-  shift = shift % (ssize_t)len;
+  shift = len == 0 ? 0 : shift % (ssize_t)len;
   if (shift < 0)
     shift += len;