https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121805
--- Comment #9 from federico <federico.perini at gmail dot com> ---
Thank you Mikael and Steve. Because it works, I tried an array->array pointer
with the same byte pattern:
```
program pointer_array_to_array
integer, target :: idx(16), i, array_sum
integer, pointer :: dd(:)
idx = [((i+1)/2,i=1,16)]
dd=>idx(1::2) ! same 8-byte stride pattern
array_sum = sum(idx(dd))
if (array_sum /= 20) stop 1
end program
```
The internal loop to the array sets
```
D.3050 = *(integer(kind=4) *) (dd.data + (sizetype) ((dd.dim[0].stride *
NON_LVALUE_EXPR <S.2>) * 4));
val.1 = idx[(integer(kind=8)) D.3050 + -1] + val.1;
```
compare to the previous pointer-array-to-struct:
```
D.3058 = *(integer(kind=4) *) (dd.data + (sizetype) ((dd.dim[0].stride *
NON_LVALUE_EXPR <S.3>) * 4));
val.2 = idx[(integer(kind=8)) D.3058 + -1] + val.2;
```
The array loop has the exact same definition.
The pointer descriptor is different:
For pointer->struct (the bound math did not chance anything):
dd.span = 8;
dd.dtype = {.elem_len=4, .version=0, .rank=1, .type=1};
dd.dim[0].lbound = 1;
dd.dim[0].ubound = 8;
dd.dim[0].stride = 1;
dd.data = (void *) &e[0].data;
dd.offset = -1;
For pointer->array:
dd.span = 4;
dd.dtype = {.elem_len=4, .version=0, .rank=1, .type=1};
dd.dim[0].lbound = 1;
dd.dim[0].ubound = 8;
dd.dim[0].stride = 2;
dd.data = (void *) &idx[0];
dd.offset = -2;
but both descriptors also look right:
the array one "jumps" in 4-byte increments with stride=2;
the pointer one "jumps" in 8-byte increments (the struct storage size) with
stride = 1.
Then what I think is wrong is the byte size of the "jump" in the loop: it is
hardcoded as `*4` but maybe it should be `dd.span` instead?
```
D.3050 = *(integer(kind=4) *) (dd.data + (sizetype) ((dd.dim[0].stride *
NON_LVALUE_EXPR <S.2>) * dd.span); // <<<< note dd.span
``