Hi Mikael,

Am 06.11.23 um 20:19 schrieb Mikael Morin:

This change to the testcase:

diff --git a/gcc/testsuite/gfortran.dg/bound_11.f90
b/gcc/testsuite/gfortran.dg/bound_11.f90
index 170eba4ddfd..2e96f843476 100644
--- a/gcc/testsuite/gfortran.dg/bound_11.f90
+++ b/gcc/testsuite/gfortran.dg/bound_11.f90
@@ -88,6 +88,7 @@ contains
      m4 = .false.
      i = 1
      r = sum(a, dim=i)
+    if (.not. allocated(r)) stop 210
      if (any(shape(r) /= (/ 3, 0, 7 /))) stop 211
      if (any(ubound(r) /= (/ 3, 0, 7 /))) stop 212
      i = 2
@@ -104,6 +105,7 @@ contains
      if (any(ubound(r) /= (/ 9, 3, 0 /))) stop 218
      i = 1
      r = sum(a, dim=i, mask=m1)
+    if (.not. allocated(r)) stop 220
      if (any(shape(r) /= (/ 3, 0, 7 /))) stop 221
      if (any(ubound(r) /= (/ 3, 0, 7 /))) stop 222
      i = 2
@@ -120,6 +122,7 @@ contains
      if (any(ubound(r) /= (/ 9, 3, 0 /))) stop 228
      i = 1
      r = sum(a, dim=i, mask=m4)
+    if (.not. allocated(r)) stop 230
      if (any(shape(r) /= (/ 3, 0, 7 /))) stop 231
      if (any(ubound(r) /= (/ 3, 0, 7 /))) stop 232
      i = 2

gives me a FAIL with STOP 220 (or STOP 230 if the STOP 220 line is
commented); the first one with STOP 210 passes.
So it is the first snippet with the xmallocarray (which supports zero
values see memory.c) call that is the correct one.
Good catch, I will open a separate PR.

ah, now I see that the case of allocation of zero elements
always allocates one byte, which is needed for r.data to be
non-null.

Go ahead!

Harald


Mikael


Reply via email to