https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128969
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The ICE issue is now FIXED.
And I now understand the WRONG-CODE issue; I am just not sure whether that's a
compiler or a run-time issue:
'gq' is 'declare target' and, hence, has infinite reference count. Then comes:
!$omp target enter data map(to: gq%v1)
!$omp target teams distribute parallel do ! implicit: 'map(tofrom: gq)'
As 'gq' is already present on the device, 'gq' is not updated on the device
such that the array descriptor is not updated – and stays zero initialized.
Thus, in particular lower-bound = upper bound = 0 + and offset not '-1' but
'0':
("gq.v1.offset").
For i = 1 (first element) the memory access is 'q.v1->data[i + offset]' which
accesses the second element '[1]' instead of the first one '[0]'.
* * *
A fix is using the 'always' modifier.
[RFC] The question is what should happen when just mapping it (as above)
without 'always' but with a previously unallocated 'gq%v1'?!?
Currently, only the pointer is attached - and the array descriptor not updated.
It seems as if the Cray compiler has the same issue while Flang and nvfortran
update the descriptor.
cf.
https://offtarget.sh/issues/stress--gcc-declare-target-allocatable-component-ice.html