This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/35001] shape for negative sizes



------- Comment #1 from tkoenig at gcc dot gnu dot org  2008-01-31 21:10 -------
A patch for when trunk reopens.

Index: m4/shape.m4
===================================================================
--- m4/shape.m4 (revision 131915)
+++ m4/shape.m4 (working copy)
@@ -46,6 +46,7 @@ shape_'rtype_kind` ('rtype` * const rest
 {
   int n;
   index_type stride;
+  index_type extent;

   stride = ret->dim[0].stride;

@@ -54,8 +55,8 @@ shape_'rtype_kind` ('rtype` * const rest

   for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
     {
-      ret->data[n * stride] =
-        array->dim[n].ubound + 1 - array->dim[n].lbound;
+      extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      ret->data[n * stride] = extent > 0 ? extent : 0 ;
     }
 }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35001


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]