[Bug fortran/102043] Wrong array types used for negative stride accesses
tkoenig at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Nov 14 07:57:53 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102043
--- Comment #13 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #12)
> (In reply to Thomas Koenig from comment #11)
> > (In reply to Richard Biener from comment #10)
> >
> > > 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?
> >
> > I've tried, but I have been unable to find such a test case, and
> > I do not think this can (or should) happen.
>
> I would say it can happen as things stand, when one dimension is accessed
> going backward and another going forward.
>
You're right.
The test case is actually quite interesting, it shows a
discrepancy between scalarization and indexed access even
in earlier versions:
$ cat a.f90
program main
implicit none
integer :: a(4, 4)
a = 0
call s(a(4:1:-1,:))
print '(4(I4))',a
if (any(a /= 2)) stop 1
contains
subroutine s(b)
implicit none
integer, dimension(:,:) :: b
b = 2
end subroutine s
end program main
$ gfortran -v
[...]
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
$ gfortran a.f90
$ ./a.out
2 2 2 2
2 2 2 2
2 2 2 2
2 2 2 2
$ gfortran -O3 a.f90
$ ./a.out
2 2 2 2
2 2 2 2
2 2 2 2
2 2 2 2
STOP 1
the same result I get with a fairly recent trunk.
More information about the Gcc-bugs
mailing list