]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/generated/maxval_i4.c
libgfortran: Don't skip allocation if size is zero [PR112412]
[thirdparty/gcc.git] / libgfortran / generated / maxval_i4.c
index 99248447c315c1060a2319a1c2e8a7df1212af83..0412c7a75834f2a72f32e3d37fc8d0c2fe721e7e 100644 (file)
@@ -315,15 +315,13 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
+      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
       if (alloc_size == 0)
        {
          /* Make sure we have a zero-sized array.  */
          GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
          return;
        }
-      else
-       retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
-
     }
   else
     {
@@ -508,14 +506,13 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
 
+      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
       if (alloc_size == 0)
        {
          /* Make sure we have a zero-sized array.  */
          GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
          return;
        }
-      else
-       retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
     }
   else
     {