https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115259
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The error exacted message "Incorrect extent in return value of ALL intrinsic in
dimension" comes from _gfortran_all_l4 which is defined in
gfortran/generated/all_l4.c .
This is the code which does the check:
```
if (extent[n] != ret_extent)
runtime_error ("Incorrect extent in return value of"
" ALL intrinsic in dimension %d:"
" is %ld, should be %ld", (int) n + 1,
(long int) ret_extent, (long int) extent[n]);
```
It is (long int) extent[n] that is giving the garbage.
extent is handled with:
```
index_type extent[GFC_MAX_DIMENSIONS];
for (n = 0; n < dim; n++)
{
sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
if (extent[n] < 0)
extent[n] = 0;
}
for (n = dim; n < rank; n++)
{
sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
if (extent[n] < 0)
extent[n] = 0;
}
```
GFC_DESCRIPTOR_EXTENT is defined as:
```
#define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
- (desc)->dim[i].lower_bound)
```
returnvect (ret_extent)
```
parm.2.dim[0].lbound = 1;
parm.2.dim[0].ubound = 3;
parm.2.dim[0].stride = 1;
```
is 2.
```
f.dim[0].lbound = 1;
f.dim[0].ubound = 2;
...
_146 = f.dim[0].lbound;
_147 = f.dim[0].ubound;
...
parm.3.dim[0].lbound = 1;
_98 = 1 - _146;
_99 = _147 + _98;
parm.3.dim[0].ubound = _99;
parm.3.dim[0].stride = 1;
```
is 3
Someone who knows GCN will have to debug it further but I suspect
gfortran/generated/all_l4.c is being miscompiled.
The failures all look like they call into this same function (or similar
function, that is the _gfortran_all_* functions which is all similar code).
In the case of xmallocarray failure it comes from:
```
alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_4));
```
So if the extent array initialization is messed up, then all will be messed up.