This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/35991] run-time abort for CSHIFT of zero sized array
- From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Apr 2008 20:16:59 -0000
- Subject: [Bug fortran/35991] run-time abort for CSHIFT of zero sized array
- References: <bug-35991-15620@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from jvdelisle at gcc dot gnu dot org 2008-04-20 20:16 -------
This obvious patch fixes it.
Index: cshift0.c
===================================================================
--- cshift0.c (revision 134473)
+++ cshift0.c (working copy)
@@ -202,7 +202,7 @@ cshift0 (gfc_array_char * ret, const gfc
rptr = ret->data;
sptr = array->data;
- shift = shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ssize_t)len;
if (shift < 0)
shift += len;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35991