diff --git a/gcc/testsuite/gfortran.dg/bound_10.f90 b/gcc/testsuite/gfortran.dg/bound_10.f90
new file mode 100644
index 00000000000..cbe065cf2b6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bound_10.f90
@@ -0,0 +1,207 @@
+! { dg-do run }
+!
+! PR fortran/112371
+! The library used to not set the bounds and content of the resulting array
+! of a reduction function if the input array had zero extent along the
+! reduction dimension.
+
+program p
+  implicit none
+  call check_iall
+  call check_iany
+  call check_iparity
+  call check_minloc_int
+  call check_minloc_char
+  call check_maxloc_real
+  call check_maxloc_char
+  call check_minval_int
+  call check_minval_char
+  call check_maxval_real
+  call check_maxval_char
+  call check_sum
+  call check_product
+contains
+  subroutine check_iall
+    integer :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = iall(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 11
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 12
+    if (any(shape(r) /= (/ 3, 2 /))) stop 13
+    if (any(r /= int(z'FFFFFFFF'))) stop 14
+  end subroutine
+  subroutine check_iany
+    integer(kind=8) :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer(kind=8), allocatable :: r(:,:)
+    a = reshape((/ integer(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = iany(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 21
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 22
+    if (any(shape(r) /= (/ 2, 3 /))) stop 23
+    if (any(r /= 0)) stop 24
+  end subroutine
+  subroutine check_iparity
+    integer(kind=2) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer(kind=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = iparity(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 31
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 32
+    if (any(shape(r) /= (/ 2, 3 /))) stop 33
+    if (any(r /= 0)) stop 34
+  end subroutine
+  subroutine check_minloc_int
+    integer :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i, j
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = minloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 41
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 42
+    if (any(shape(r) /= (/ 3, 2 /))) stop 43
+    if (any(r /= 0)) stop 44
+  end subroutine
+  subroutine check_minloc_char
+    character :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ character:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = minloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 51
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 52
+    if (any(shape(r) /= (/ 2, 3 /))) stop 53
+    if (any(r /= 0)) stop 54
+  end subroutine
+  subroutine check_maxloc_real
+    real :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ real:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = maxloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 61
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 62
+    if (any(shape(r) /= (/ 2, 3 /))) stop 63
+    if (any(r /= 0)) stop 64
+  end subroutine
+  subroutine check_maxloc_char
+    character(len=2) :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ character(len=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = maxloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 71
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 72
+    if (any(shape(r) /= (/ 3, 2 /))) stop 73
+    if (any(r /= 0)) stop 74
+  end subroutine
+  subroutine check_minval_int
+    integer(kind=2) :: a(3,2,0)
+    logical(kind=1) :: m(3,2,0)
+    integer :: i, j
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer(kind=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = minval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 81
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 82
+    if (any(shape(r) /= (/ 3, 2 /))) stop 83
+    if (any(r /= huge(1_2))) stop 84
+  end subroutine
+  subroutine check_minval_char
+    character(kind=4) :: a(0,3,2)
+    logical(kind=1) :: m(0,3,2)
+    integer :: i
+    character(kind=4), allocatable :: r(:,:)
+    a = reshape((/ character(kind=4):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = minval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 91
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 92
+    if (any(shape(r) /= (/ 3, 2 /))) stop 93
+    if (any(r /= char(int(z'FFFFFFFF', kind=8), kind=4))) stop 94
+  end subroutine
+  subroutine check_maxval_real
+    real(kind=8) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    real(kind=8), allocatable :: r(:,:)
+    a = reshape((/ real(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = maxval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 101
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 102
+    if (any(shape(r) /= (/ 2, 3 /))) stop 103
+    if (any(r /= -huge(1._8))) stop 104
+  end subroutine
+  subroutine check_maxval_char
+    character(kind=4,len=2) :: a(3,0,2), e
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    character(len=2,kind=4), allocatable :: r(:,:)
+    a = reshape((/ character(kind=4,len=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = maxval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 111
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 112
+    if (any(shape(r) /= (/ 3, 2 /))) stop 113
+    e = repeat(char(0, kind=4), len(a))
+    if (any(r /= e)) stop 114
+  end subroutine
+  subroutine check_sum
+    integer(kind=1) :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = sum(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 121
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 122
+    if (any(shape(r) /= (/ 2, 3 /))) stop 123
+    if (any(r /= 0)) stop 124
+  end subroutine
+  subroutine check_product
+    real(kind=8) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ real(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = product(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 131
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 132
+    if (any(shape(r) /= (/ 2, 3 /))) stop 133
+    if (any(r /= 1.0_8)) stop 134
+  end subroutine
+end program
diff --git a/libgfortran/generated/iall_i1.c b/libgfortran/generated/iall_i1.c
index c9696c92485..2236f044e65 100644
--- a/libgfortran/generated/iall_i1.c
+++ b/libgfortran/generated/iall_i1.c
@@ -242,8 +242,8 @@ miall_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i16.c b/libgfortran/generated/iall_i16.c
index f0a1b3adcf2..96ca5a57c9c 100644
--- a/libgfortran/generated/iall_i16.c
+++ b/libgfortran/generated/iall_i16.c
@@ -242,8 +242,8 @@ miall_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i2.c b/libgfortran/generated/iall_i2.c
index 4d14d71cab2..4d895db2b35 100644
--- a/libgfortran/generated/iall_i2.c
+++ b/libgfortran/generated/iall_i2.c
@@ -242,8 +242,8 @@ miall_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i4.c b/libgfortran/generated/iall_i4.c
index cb7ce755bfc..673e9809483 100644
--- a/libgfortran/generated/iall_i4.c
+++ b/libgfortran/generated/iall_i4.c
@@ -242,8 +242,8 @@ miall_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i8.c b/libgfortran/generated/iall_i8.c
index c7dab3e2e56..4de6ff1782d 100644
--- a/libgfortran/generated/iall_i8.c
+++ b/libgfortran/generated/iall_i8.c
@@ -242,8 +242,8 @@ miall_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i1.c b/libgfortran/generated/iany_i1.c
index 539c5389561..ab191d6bdd2 100644
--- a/libgfortran/generated/iany_i1.c
+++ b/libgfortran/generated/iany_i1.c
@@ -242,8 +242,8 @@ miany_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i16.c b/libgfortran/generated/iany_i16.c
index d690dff60be..8fda0efea82 100644
--- a/libgfortran/generated/iany_i16.c
+++ b/libgfortran/generated/iany_i16.c
@@ -242,8 +242,8 @@ miany_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i2.c b/libgfortran/generated/iany_i2.c
index dd37c1e5b48..43080b85992 100644
--- a/libgfortran/generated/iany_i2.c
+++ b/libgfortran/generated/iany_i2.c
@@ -242,8 +242,8 @@ miany_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i4.c b/libgfortran/generated/iany_i4.c
index e9689904951..d8430ca4e90 100644
--- a/libgfortran/generated/iany_i4.c
+++ b/libgfortran/generated/iany_i4.c
@@ -242,8 +242,8 @@ miany_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i8.c b/libgfortran/generated/iany_i8.c
index 79f6c381a3f..7d3ac16412d 100644
--- a/libgfortran/generated/iany_i8.c
+++ b/libgfortran/generated/iany_i8.c
@@ -242,8 +242,8 @@ miany_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i1.c b/libgfortran/generated/iparity_i1.c
index 8e0f4529d4d..53b15cbb73f 100644
--- a/libgfortran/generated/iparity_i1.c
+++ b/libgfortran/generated/iparity_i1.c
@@ -242,8 +242,8 @@ miparity_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i16.c b/libgfortran/generated/iparity_i16.c
index 912ca591dda..848ac6284fb 100644
--- a/libgfortran/generated/iparity_i16.c
+++ b/libgfortran/generated/iparity_i16.c
@@ -242,8 +242,8 @@ miparity_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i2.c b/libgfortran/generated/iparity_i2.c
index 6e7e60a5a2e..f435fd27edd 100644
--- a/libgfortran/generated/iparity_i2.c
+++ b/libgfortran/generated/iparity_i2.c
@@ -242,8 +242,8 @@ miparity_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i4.c b/libgfortran/generated/iparity_i4.c
index 0bb1be1dedb..ea876bdd31a 100644
--- a/libgfortran/generated/iparity_i4.c
+++ b/libgfortran/generated/iparity_i4.c
@@ -242,8 +242,8 @@ miparity_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i8.c b/libgfortran/generated/iparity_i8.c
index e219d6e3dce..0fee2e5025d 100644
--- a/libgfortran/generated/iparity_i8.c
+++ b/libgfortran/generated/iparity_i8.c
@@ -242,8 +242,8 @@ miparity_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c
index e126c18bc80..bc0643cde1e 100644
--- a/libgfortran/generated/maxloc1_16_i1.c
+++ b/libgfortran/generated/maxloc1_16_i1.c
@@ -270,8 +270,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c
index 04ced535df9..5dca85c4bc0 100644
--- a/libgfortran/generated/maxloc1_16_i16.c
+++ b/libgfortran/generated/maxloc1_16_i16.c
@@ -270,8 +270,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c
index 9f7447e9de9..118d7c527a1 100644
--- a/libgfortran/generated/maxloc1_16_i2.c
+++ b/libgfortran/generated/maxloc1_16_i2.c
@@ -270,8 +270,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c
index 8663dfc7e24..858dfc0e850 100644
--- a/libgfortran/generated/maxloc1_16_i4.c
+++ b/libgfortran/generated/maxloc1_16_i4.c
@@ -270,8 +270,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c
index c0593a67f11..36469e49797 100644
--- a/libgfortran/generated/maxloc1_16_i8.c
+++ b/libgfortran/generated/maxloc1_16_i8.c
@@ -270,8 +270,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c
index a5e0665fccf..dfc55681b1f 100644
--- a/libgfortran/generated/maxloc1_16_r10.c
+++ b/libgfortran/generated/maxloc1_16_r10.c
@@ -270,8 +270,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c
index cbb20002665..17daa796afc 100644
--- a/libgfortran/generated/maxloc1_16_r16.c
+++ b/libgfortran/generated/maxloc1_16_r16.c
@@ -270,8 +270,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r17.c b/libgfortran/generated/maxloc1_16_r17.c
index 719ae09772d..46fd4ab320c 100644
--- a/libgfortran/generated/maxloc1_16_r17.c
+++ b/libgfortran/generated/maxloc1_16_r17.c
@@ -270,8 +270,8 @@ mmaxloc1_16_r17 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c
index 37a0657dab2..b52932f70bf 100644
--- a/libgfortran/generated/maxloc1_16_r4.c
+++ b/libgfortran/generated/maxloc1_16_r4.c
@@ -270,8 +270,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c
index 305613694b2..c26c4b4ed0a 100644
--- a/libgfortran/generated/maxloc1_16_r8.c
+++ b/libgfortran/generated/maxloc1_16_r8.c
@@ -270,8 +270,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_s1.c b/libgfortran/generated/maxloc1_16_s1.c
index b9a8a639596..54f57238367 100644
--- a/libgfortran/generated/maxloc1_16_s1.c
+++ b/libgfortran/generated/maxloc1_16_s1.c
@@ -263,8 +263,8 @@ mmaxloc1_16_s1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_s4.c b/libgfortran/generated/maxloc1_16_s4.c
index fdaad7fd2dc..eb015eabef2 100644
--- a/libgfortran/generated/maxloc1_16_s4.c
+++ b/libgfortran/generated/maxloc1_16_s4.c
@@ -263,8 +263,8 @@ mmaxloc1_16_s4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c
index b68d92ef44e..4b0bd56a60b 100644
--- a/libgfortran/generated/maxloc1_4_i1.c
+++ b/libgfortran/generated/maxloc1_4_i1.c
@@ -270,8 +270,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c
index 9221e22505b..d976d2d4b8e 100644
--- a/libgfortran/generated/maxloc1_4_i16.c
+++ b/libgfortran/generated/maxloc1_4_i16.c
@@ -270,8 +270,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c
index 3fa2e367898..ba8228925d4 100644
--- a/libgfortran/generated/maxloc1_4_i2.c
+++ b/libgfortran/generated/maxloc1_4_i2.c
@@ -270,8 +270,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c
index 5ef2abb98e1..644e48e547f 100644
--- a/libgfortran/generated/maxloc1_4_i4.c
+++ b/libgfortran/generated/maxloc1_4_i4.c
@@ -270,8 +270,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c
index 102d394b309..fd5d31b5162 100644
--- a/libgfortran/generated/maxloc1_4_i8.c
+++ b/libgfortran/generated/maxloc1_4_i8.c
@@ -270,8 +270,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c
index 623204d792c..00c90fa3c66 100644
--- a/libgfortran/generated/maxloc1_4_r10.c
+++ b/libgfortran/generated/maxloc1_4_r10.c
@@ -270,8 +270,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c
index 92209ce79ce..92372b8d837 100644
--- a/libgfortran/generated/maxloc1_4_r16.c
+++ b/libgfortran/generated/maxloc1_4_r16.c
@@ -270,8 +270,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r17.c b/libgfortran/generated/maxloc1_4_r17.c
index 6ee34b52719..10c68752188 100644
--- a/libgfortran/generated/maxloc1_4_r17.c
+++ b/libgfortran/generated/maxloc1_4_r17.c
@@ -270,8 +270,8 @@ mmaxloc1_4_r17 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c
index ea6123a987c..b0750c19361 100644
--- a/libgfortran/generated/maxloc1_4_r4.c
+++ b/libgfortran/generated/maxloc1_4_r4.c
@@ -270,8 +270,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c
index ba83b4d6a6d..3be87685eed 100644
--- a/libgfortran/generated/maxloc1_4_r8.c
+++ b/libgfortran/generated/maxloc1_4_r8.c
@@ -270,8 +270,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_s1.c b/libgfortran/generated/maxloc1_4_s1.c
index 7d2ab07915e..91628645d1c 100644
--- a/libgfortran/generated/maxloc1_4_s1.c
+++ b/libgfortran/generated/maxloc1_4_s1.c
@@ -263,8 +263,8 @@ mmaxloc1_4_s1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_s4.c b/libgfortran/generated/maxloc1_4_s4.c
index 7a4950d3e5c..7cb056ea10b 100644
--- a/libgfortran/generated/maxloc1_4_s4.c
+++ b/libgfortran/generated/maxloc1_4_s4.c
@@ -263,8 +263,8 @@ mmaxloc1_4_s4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c
index d243e6e027c..42b113b1d0c 100644
--- a/libgfortran/generated/maxloc1_8_i1.c
+++ b/libgfortran/generated/maxloc1_8_i1.c
@@ -270,8 +270,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c
index 5871aa52379..594c735ad77 100644
--- a/libgfortran/generated/maxloc1_8_i16.c
+++ b/libgfortran/generated/maxloc1_8_i16.c
@@ -270,8 +270,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c
index 9337f47c9ca..9e141af3ecd 100644
--- a/libgfortran/generated/maxloc1_8_i2.c
+++ b/libgfortran/generated/maxloc1_8_i2.c
@@ -270,8 +270,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c
index 747b9979fdc..b94c627dfd6 100644
--- a/libgfortran/generated/maxloc1_8_i4.c
+++ b/libgfortran/generated/maxloc1_8_i4.c
@@ -270,8 +270,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c
index adc0ebae28d..18e45033b40 100644
--- a/libgfortran/generated/maxloc1_8_i8.c
+++ b/libgfortran/generated/maxloc1_8_i8.c
@@ -270,8 +270,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c
index 4c8d00d937d..22cd8c26e1b 100644
--- a/libgfortran/generated/maxloc1_8_r10.c
+++ b/libgfortran/generated/maxloc1_8_r10.c
@@ -270,8 +270,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c
index df3edbe611b..646fe18a975 100644
--- a/libgfortran/generated/maxloc1_8_r16.c
+++ b/libgfortran/generated/maxloc1_8_r16.c
@@ -270,8 +270,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r17.c b/libgfortran/generated/maxloc1_8_r17.c
index 162806132f1..cc6bb86546c 100644
--- a/libgfortran/generated/maxloc1_8_r17.c
+++ b/libgfortran/generated/maxloc1_8_r17.c
@@ -270,8 +270,8 @@ mmaxloc1_8_r17 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c
index dee860a1a8f..2c482bc8ed4 100644
--- a/libgfortran/generated/maxloc1_8_r4.c
+++ b/libgfortran/generated/maxloc1_8_r4.c
@@ -270,8 +270,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c
index 215d9668adb..32452d49ff3 100644
--- a/libgfortran/generated/maxloc1_8_r8.c
+++ b/libgfortran/generated/maxloc1_8_r8.c
@@ -270,8 +270,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_s1.c b/libgfortran/generated/maxloc1_8_s1.c
index 7b1091d596c..96ac1ac0bd4 100644
--- a/libgfortran/generated/maxloc1_8_s1.c
+++ b/libgfortran/generated/maxloc1_8_s1.c
@@ -263,8 +263,8 @@ mmaxloc1_8_s1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_s4.c b/libgfortran/generated/maxloc1_8_s4.c
index a61c08c6f64..068c4ff7a72 100644
--- a/libgfortran/generated/maxloc1_8_s4.c
+++ b/libgfortran/generated/maxloc1_8_s4.c
@@ -263,8 +263,8 @@ mmaxloc1_8_s4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval1_s1.c b/libgfortran/generated/maxval1_s1.c
index fd65f4b62ec..6ad5366b8f3 100644
--- a/libgfortran/generated/maxval1_s1.c
+++ b/libgfortran/generated/maxval1_s1.c
@@ -258,8 +258,8 @@ mmaxval1_s1 (gfc_array_s1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval1_s4.c b/libgfortran/generated/maxval1_s4.c
index 3558e61c76a..6337b043a3e 100644
--- a/libgfortran/generated/maxval1_s4.c
+++ b/libgfortran/generated/maxval1_s4.c
@@ -258,8 +258,8 @@ mmaxval1_s4 (gfc_array_s4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c
index bc52cd74a95..19feced6861 100644
--- a/libgfortran/generated/maxval_i1.c
+++ b/libgfortran/generated/maxval_i1.c
@@ -256,8 +256,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c
index 1d9d33369d4..cd75603b066 100644
--- a/libgfortran/generated/maxval_i16.c
+++ b/libgfortran/generated/maxval_i16.c
@@ -256,8 +256,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c
index fe3c6fecce7..9c7eb7702e3 100644
--- a/libgfortran/generated/maxval_i2.c
+++ b/libgfortran/generated/maxval_i2.c
@@ -256,8 +256,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c
index 0412c7a7583..40bf1ce97ab 100644
--- a/libgfortran/generated/maxval_i4.c
+++ b/libgfortran/generated/maxval_i4.c
@@ -256,8 +256,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c
index 2037b96b3c5..0b6b9f671ee 100644
--- a/libgfortran/generated/maxval_i8.c
+++ b/libgfortran/generated/maxval_i8.c
@@ -256,8 +256,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c
index 7c397eeea77..f83c4e9965a 100644
--- a/libgfortran/generated/maxval_r10.c
+++ b/libgfortran/generated/maxval_r10.c
@@ -256,8 +256,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c
index 1f2144e5253..ec2d7a92be5 100644
--- a/libgfortran/generated/maxval_r16.c
+++ b/libgfortran/generated/maxval_r16.c
@@ -256,8 +256,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r17.c b/libgfortran/generated/maxval_r17.c
index f85460366aa..442e2b3a387 100644
--- a/libgfortran/generated/maxval_r17.c
+++ b/libgfortran/generated/maxval_r17.c
@@ -256,8 +256,8 @@ mmaxval_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c
index e2fd59e92bc..6c08b342752 100644
--- a/libgfortran/generated/maxval_r4.c
+++ b/libgfortran/generated/maxval_r4.c
@@ -256,8 +256,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c
index d3aadc62529..30d259f7708 100644
--- a/libgfortran/generated/maxval_r8.c
+++ b/libgfortran/generated/maxval_r8.c
@@ -256,8 +256,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c
index 541d71fe214..80abb3cf8e0 100644
--- a/libgfortran/generated/minloc1_16_i1.c
+++ b/libgfortran/generated/minloc1_16_i1.c
@@ -280,8 +280,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c
index baaf02597b6..388a8f91208 100644
--- a/libgfortran/generated/minloc1_16_i16.c
+++ b/libgfortran/generated/minloc1_16_i16.c
@@ -280,8 +280,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c
index e4f78b65de3..51ae92b91fb 100644
--- a/libgfortran/generated/minloc1_16_i2.c
+++ b/libgfortran/generated/minloc1_16_i2.c
@@ -280,8 +280,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c
index c561d71319e..675fc333d52 100644
--- a/libgfortran/generated/minloc1_16_i4.c
+++ b/libgfortran/generated/minloc1_16_i4.c
@@ -280,8 +280,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c
index ebdb68dd3c5..6a417880a12 100644
--- a/libgfortran/generated/minloc1_16_i8.c
+++ b/libgfortran/generated/minloc1_16_i8.c
@@ -280,8 +280,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c
index 98d3fb3879b..f5d9c347ef9 100644
--- a/libgfortran/generated/minloc1_16_r10.c
+++ b/libgfortran/generated/minloc1_16_r10.c
@@ -280,8 +280,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c
index ad445a42dfa..3405c0e4bef 100644
--- a/libgfortran/generated/minloc1_16_r16.c
+++ b/libgfortran/generated/minloc1_16_r16.c
@@ -280,8 +280,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r17.c b/libgfortran/generated/minloc1_16_r17.c
index 339d9ad9662..e3d0d417e5d 100644
--- a/libgfortran/generated/minloc1_16_r17.c
+++ b/libgfortran/generated/minloc1_16_r17.c
@@ -280,8 +280,8 @@ mminloc1_16_r17 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c
index 780bcc267fd..8af09702f5c 100644
--- a/libgfortran/generated/minloc1_16_r4.c
+++ b/libgfortran/generated/minloc1_16_r4.c
@@ -280,8 +280,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c
index 124587f5fb3..9397dc6ff91 100644
--- a/libgfortran/generated/minloc1_16_r8.c
+++ b/libgfortran/generated/minloc1_16_r8.c
@@ -280,8 +280,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_s1.c b/libgfortran/generated/minloc1_16_s1.c
index f4763dc6e64..c6d8861a5f4 100644
--- a/libgfortran/generated/minloc1_16_s1.c
+++ b/libgfortran/generated/minloc1_16_s1.c
@@ -263,8 +263,8 @@ mminloc1_16_s1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_s4.c b/libgfortran/generated/minloc1_16_s4.c
index ba0475a9ca0..0f5eb2db869 100644
--- a/libgfortran/generated/minloc1_16_s4.c
+++ b/libgfortran/generated/minloc1_16_s4.c
@@ -263,8 +263,8 @@ mminloc1_16_s4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c
index 433a25a8ef8..4274e70dc92 100644
--- a/libgfortran/generated/minloc1_4_i1.c
+++ b/libgfortran/generated/minloc1_4_i1.c
@@ -280,8 +280,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c
index 9d2c606186b..ded68f0b0fb 100644
--- a/libgfortran/generated/minloc1_4_i16.c
+++ b/libgfortran/generated/minloc1_4_i16.c
@@ -280,8 +280,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c
index 73737011e9a..a053dd352e5 100644
--- a/libgfortran/generated/minloc1_4_i2.c
+++ b/libgfortran/generated/minloc1_4_i2.c
@@ -280,8 +280,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c
index d18416ebcc4..6292fc2d9b7 100644
--- a/libgfortran/generated/minloc1_4_i4.c
+++ b/libgfortran/generated/minloc1_4_i4.c
@@ -280,8 +280,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c
index 4f7dfdfdf73..9240e3fe5bd 100644
--- a/libgfortran/generated/minloc1_4_i8.c
+++ b/libgfortran/generated/minloc1_4_i8.c
@@ -280,8 +280,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c
index ff5af01130d..42a9de0b6d0 100644
--- a/libgfortran/generated/minloc1_4_r10.c
+++ b/libgfortran/generated/minloc1_4_r10.c
@@ -280,8 +280,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c
index 2d664467df3..06193f13598 100644
--- a/libgfortran/generated/minloc1_4_r16.c
+++ b/libgfortran/generated/minloc1_4_r16.c
@@ -280,8 +280,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r17.c b/libgfortran/generated/minloc1_4_r17.c
index 711fd841d34..d021d46b9fa 100644
--- a/libgfortran/generated/minloc1_4_r17.c
+++ b/libgfortran/generated/minloc1_4_r17.c
@@ -280,8 +280,8 @@ mminloc1_4_r17 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c
index 0739d9bd178..e6990c6e70e 100644
--- a/libgfortran/generated/minloc1_4_r4.c
+++ b/libgfortran/generated/minloc1_4_r4.c
@@ -280,8 +280,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c
index d625195e432..fd1574f6413 100644
--- a/libgfortran/generated/minloc1_4_r8.c
+++ b/libgfortran/generated/minloc1_4_r8.c
@@ -280,8 +280,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_s1.c b/libgfortran/generated/minloc1_4_s1.c
index 13ebc76524d..5bbc844e196 100644
--- a/libgfortran/generated/minloc1_4_s1.c
+++ b/libgfortran/generated/minloc1_4_s1.c
@@ -263,8 +263,8 @@ mminloc1_4_s1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_s4.c b/libgfortran/generated/minloc1_4_s4.c
index 5c9a5900237..4f2ab20ab9f 100644
--- a/libgfortran/generated/minloc1_4_s4.c
+++ b/libgfortran/generated/minloc1_4_s4.c
@@ -263,8 +263,8 @@ mminloc1_4_s4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c
index fab5619979f..1b8b24064d9 100644
--- a/libgfortran/generated/minloc1_8_i1.c
+++ b/libgfortran/generated/minloc1_8_i1.c
@@ -280,8 +280,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c
index 742e2ea73b2..9561270e150 100644
--- a/libgfortran/generated/minloc1_8_i16.c
+++ b/libgfortran/generated/minloc1_8_i16.c
@@ -280,8 +280,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c
index defef3c653c..979856579f9 100644
--- a/libgfortran/generated/minloc1_8_i2.c
+++ b/libgfortran/generated/minloc1_8_i2.c
@@ -280,8 +280,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c
index 3e696aafcac..1c303ed6dea 100644
--- a/libgfortran/generated/minloc1_8_i4.c
+++ b/libgfortran/generated/minloc1_8_i4.c
@@ -280,8 +280,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c
index 9a017433ee6..6249f20ae62 100644
--- a/libgfortran/generated/minloc1_8_i8.c
+++ b/libgfortran/generated/minloc1_8_i8.c
@@ -280,8 +280,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c
index 18f294f2180..2c6a0fd8a58 100644
--- a/libgfortran/generated/minloc1_8_r10.c
+++ b/libgfortran/generated/minloc1_8_r10.c
@@ -280,8 +280,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c
index 1dd45dead26..f7d06648c37 100644
--- a/libgfortran/generated/minloc1_8_r16.c
+++ b/libgfortran/generated/minloc1_8_r16.c
@@ -280,8 +280,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r17.c b/libgfortran/generated/minloc1_8_r17.c
index 85dc6cb04fe..0cc70c439d0 100644
--- a/libgfortran/generated/minloc1_8_r17.c
+++ b/libgfortran/generated/minloc1_8_r17.c
@@ -280,8 +280,8 @@ mminloc1_8_r17 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c
index 6d7764a5eb7..b2ae3dfcc06 100644
--- a/libgfortran/generated/minloc1_8_r4.c
+++ b/libgfortran/generated/minloc1_8_r4.c
@@ -280,8 +280,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c
index e17d3c881c0..bafd72d0893 100644
--- a/libgfortran/generated/minloc1_8_r8.c
+++ b/libgfortran/generated/minloc1_8_r8.c
@@ -280,8 +280,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_s1.c b/libgfortran/generated/minloc1_8_s1.c
index 0449575a5a3..8a40b52a188 100644
--- a/libgfortran/generated/minloc1_8_s1.c
+++ b/libgfortran/generated/minloc1_8_s1.c
@@ -263,8 +263,8 @@ mminloc1_8_s1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_s4.c b/libgfortran/generated/minloc1_8_s4.c
index 682b89b2765..906d1df9a2e 100644
--- a/libgfortran/generated/minloc1_8_s4.c
+++ b/libgfortran/generated/minloc1_8_s4.c
@@ -263,8 +263,8 @@ mminloc1_8_s4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval1_s1.c b/libgfortran/generated/minval1_s1.c
index 9c577ed004c..d83fef19d3c 100644
--- a/libgfortran/generated/minval1_s1.c
+++ b/libgfortran/generated/minval1_s1.c
@@ -258,8 +258,8 @@ mminval1_s1 (gfc_array_s1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval1_s4.c b/libgfortran/generated/minval1_s4.c
index 9a30bf0bfb5..5ef09cdeebb 100644
--- a/libgfortran/generated/minval1_s4.c
+++ b/libgfortran/generated/minval1_s4.c
@@ -258,8 +258,8 @@ mminval1_s4 (gfc_array_s4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c
index 174161af4d4..544a996a01c 100644
--- a/libgfortran/generated/minval_i1.c
+++ b/libgfortran/generated/minval_i1.c
@@ -256,8 +256,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c
index b220391e4f8..1bcdf58792a 100644
--- a/libgfortran/generated/minval_i16.c
+++ b/libgfortran/generated/minval_i16.c
@@ -256,8 +256,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c
index 3a050c1eb82..61801f163f2 100644
--- a/libgfortran/generated/minval_i2.c
+++ b/libgfortran/generated/minval_i2.c
@@ -256,8 +256,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c
index 194967d2f92..019a880e2ab 100644
--- a/libgfortran/generated/minval_i4.c
+++ b/libgfortran/generated/minval_i4.c
@@ -256,8 +256,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c
index 07acc60d4a0..abbbd06da07 100644
--- a/libgfortran/generated/minval_i8.c
+++ b/libgfortran/generated/minval_i8.c
@@ -256,8 +256,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c
index d49244c1dff..d5b9d76d9e6 100644
--- a/libgfortran/generated/minval_r10.c
+++ b/libgfortran/generated/minval_r10.c
@@ -256,8 +256,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c
index 50305430d60..9fdde79f4fc 100644
--- a/libgfortran/generated/minval_r16.c
+++ b/libgfortran/generated/minval_r16.c
@@ -256,8 +256,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r17.c b/libgfortran/generated/minval_r17.c
index 2479a864af3..3e75af04b2d 100644
--- a/libgfortran/generated/minval_r17.c
+++ b/libgfortran/generated/minval_r17.c
@@ -256,8 +256,8 @@ mminval_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c
index ceca490cfcd..f096473e5ad 100644
--- a/libgfortran/generated/minval_r4.c
+++ b/libgfortran/generated/minval_r4.c
@@ -256,8 +256,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c
index 091cb74d30d..8fafc3c1869 100644
--- a/libgfortran/generated/minval_r8.c
+++ b/libgfortran/generated/minval_r8.c
@@ -256,8 +256,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c
index b888769130d..7ecd80e3346 100644
--- a/libgfortran/generated/product_c10.c
+++ b/libgfortran/generated/product_c10.c
@@ -242,8 +242,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c
index b783367ff05..e1d0c932a08 100644
--- a/libgfortran/generated/product_c16.c
+++ b/libgfortran/generated/product_c16.c
@@ -242,8 +242,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c17.c b/libgfortran/generated/product_c17.c
index e89e9eea0c3..2ed08b31f1e 100644
--- a/libgfortran/generated/product_c17.c
+++ b/libgfortran/generated/product_c17.c
@@ -242,8 +242,8 @@ mproduct_c17 (gfc_array_c17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c
index 08b2878930b..dbf00aacf7a 100644
--- a/libgfortran/generated/product_c4.c
+++ b/libgfortran/generated/product_c4.c
@@ -242,8 +242,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c
index cb721e50b65..1a3f27d329e 100644
--- a/libgfortran/generated/product_c8.c
+++ b/libgfortran/generated/product_c8.c
@@ -242,8 +242,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c
index 8af7d63c654..35f4f6ec804 100644
--- a/libgfortran/generated/product_i1.c
+++ b/libgfortran/generated/product_i1.c
@@ -242,8 +242,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c
index de9b7fb503a..3b815036f4f 100644
--- a/libgfortran/generated/product_i16.c
+++ b/libgfortran/generated/product_i16.c
@@ -242,8 +242,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c
index bb0283286c1..e998c0d59c3 100644
--- a/libgfortran/generated/product_i2.c
+++ b/libgfortran/generated/product_i2.c
@@ -242,8 +242,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c
index 9491031c3a8..7dbc77aff9f 100644
--- a/libgfortran/generated/product_i4.c
+++ b/libgfortran/generated/product_i4.c
@@ -242,8 +242,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c
index 49d09318335..aaa688b69ff 100644
--- a/libgfortran/generated/product_i8.c
+++ b/libgfortran/generated/product_i8.c
@@ -242,8 +242,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c
index 47af031fe90..8a7dba54fdd 100644
--- a/libgfortran/generated/product_r10.c
+++ b/libgfortran/generated/product_r10.c
@@ -242,8 +242,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c
index 3ecafc170e3..38c9922ed9b 100644
--- a/libgfortran/generated/product_r16.c
+++ b/libgfortran/generated/product_r16.c
@@ -242,8 +242,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r17.c b/libgfortran/generated/product_r17.c
index 8f79c8c9c65..37ed80c9d3a 100644
--- a/libgfortran/generated/product_r17.c
+++ b/libgfortran/generated/product_r17.c
@@ -242,8 +242,8 @@ mproduct_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c
index f9b09b3c6dc..616fd5be89d 100644
--- a/libgfortran/generated/product_r4.c
+++ b/libgfortran/generated/product_r4.c
@@ -242,8 +242,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c
index ff6aa522176..c4b710dfc6f 100644
--- a/libgfortran/generated/product_r8.c
+++ b/libgfortran/generated/product_r8.c
@@ -242,8 +242,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c
index 45018f88c6f..6de84a7e2ea 100644
--- a/libgfortran/generated/sum_c10.c
+++ b/libgfortran/generated/sum_c10.c
@@ -242,8 +242,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c
index df4297c5a84..96fc8882902 100644
--- a/libgfortran/generated/sum_c16.c
+++ b/libgfortran/generated/sum_c16.c
@@ -242,8 +242,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c17.c b/libgfortran/generated/sum_c17.c
index 65322e78989..1472fe57733 100644
--- a/libgfortran/generated/sum_c17.c
+++ b/libgfortran/generated/sum_c17.c
@@ -242,8 +242,8 @@ msum_c17 (gfc_array_c17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c
index 11ce95d53c3..250aa416cb3 100644
--- a/libgfortran/generated/sum_c4.c
+++ b/libgfortran/generated/sum_c4.c
@@ -242,8 +242,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c
index 16b9ed40e92..510a25847ac 100644
--- a/libgfortran/generated/sum_c8.c
+++ b/libgfortran/generated/sum_c8.c
@@ -242,8 +242,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c
index c2df9619f98..974522b3bbf 100644
--- a/libgfortran/generated/sum_i1.c
+++ b/libgfortran/generated/sum_i1.c
@@ -242,8 +242,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c
index d4b3d970e51..00f644bff71 100644
--- a/libgfortran/generated/sum_i16.c
+++ b/libgfortran/generated/sum_i16.c
@@ -242,8 +242,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c
index 044361c6167..448273594f4 100644
--- a/libgfortran/generated/sum_i2.c
+++ b/libgfortran/generated/sum_i2.c
@@ -242,8 +242,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c
index b37393e4c70..529fb2e94a0 100644
--- a/libgfortran/generated/sum_i4.c
+++ b/libgfortran/generated/sum_i4.c
@@ -242,8 +242,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c
index 235a98e5fb7..7b7ca72aa71 100644
--- a/libgfortran/generated/sum_i8.c
+++ b/libgfortran/generated/sum_i8.c
@@ -242,8 +242,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c
index 4e2071fa570..71e71dd91f0 100644
--- a/libgfortran/generated/sum_r10.c
+++ b/libgfortran/generated/sum_r10.c
@@ -242,8 +242,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c
index 47571d9b010..813cc33dd90 100644
--- a/libgfortran/generated/sum_r16.c
+++ b/libgfortran/generated/sum_r16.c
@@ -242,8 +242,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r17.c b/libgfortran/generated/sum_r17.c
index d479f200a80..8e82e871bb2 100644
--- a/libgfortran/generated/sum_r17.c
+++ b/libgfortran/generated/sum_r17.c
@@ -242,8 +242,8 @@ msum_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c
index 227ea34124f..1b37711b99f 100644
--- a/libgfortran/generated/sum_r4.c
+++ b/libgfortran/generated/sum_r4.c
@@ -242,8 +242,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c
index d0d0c111d4c..294211ba9be 100644
--- a/libgfortran/generated/sum_r8.c
+++ b/libgfortran/generated/sum_r8.c
@@ -242,8 +242,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction-s.m4 b/libgfortran/m4/ifunction-s.m4
index bc5ce55e81c..72793e435aa 100644
--- a/libgfortran/m4/ifunction-s.m4
+++ b/libgfortran/m4/ifunction-s.m4
@@ -244,8 +244,8 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction-s2.m4 b/libgfortran/m4/ifunction-s2.m4
index 22ba00899d7..b936d7c392c 100644
--- a/libgfortran/m4/ifunction-s2.m4
+++ b/libgfortran/m4/ifunction-s2.m4
@@ -244,8 +244,8 @@ void
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index c80aa86c890..f3ab4ebd58d 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -232,8 +232,8 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
+  if (len < 0)
+    len = 0;
 
   mbase = mask->base_addr;
 
