]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/sum_c8.c
re PR fortran/35995 (ANY, ALL, and COUNT errors for zero sized sections)
[thirdparty/gcc.git] / libgfortran / generated / sum_c8.c
index f877d09413535cfc9507df23435a1d9fb539727c..dcdcadfcda9644ba41123c91d0e4c9a6d171d0da 100644 (file)
@@ -56,12 +56,15 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
   index_type len;
   index_type delta;
   index_type dim;
+  int continue_loop;
 
   /* Make dim zero based to avoid confusion.  */
   dim = (*pdim) - 1;
   rank = GFC_DESCRIPTOR_RANK (array) - 1;
 
   len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+  if (len < 0)
+    len = 0;
   delta = array->dim[dim].stride;
 
   for (n = 0; n < dim; n++)
@@ -148,7 +151,8 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
   base = array->data;
   dest = retarray->data;
 
-  while (base)
+  continue_loop = 1;
+  while (continue_loop)
     {
       const GFC_COMPLEX_8 * restrict src;
       GFC_COMPLEX_8 result;
@@ -186,8 +190,8 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
           if (n == rank)
             {
               /* Break out of the look.  */
-              base = NULL;
-              break;
+             continue_loop = 0;
+             break;
             }
           else
             {