[Bug fortran/102043] Wrong array types used for negative stride accesses

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 11 08:00:58 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102043

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
So to clarify the ARRAY_REF constraints - there is currently no way to
construct a valid ARRAY_REF where an index does an access to memory before the
supplied
base object.  TREE_OPERAND (array_ref, 0) needs to always be the array,
it's address needs to be the address of the _first_ element.  For negative
strides gfortran seems to construct the array object in a way so its
address points to the _last_ element of the array.  That's not supported.

I realize the complication is that with array descriptors we do not know
statically whether the stride is positive or negative and the data
pointer is already set up "wrong" in there so we'd have to go and
undo the biasing which might or might not be easily possible but it will
be costly.

Is there any case where the frontend would make 'data' point into the
middle of the array and iteration over the array would end up accessing
elements on "both sides"?  Can somebody write a short testcase where that
would happen?


More information about the Gcc-bugs mailing list