| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/102043 |
| 4 |
! The middle-end used to conclude from array indexing that the index |
| 5 |
! should be non-negative and thus that array accesses to reversed arrays |
| 6 |
! (i.e. with negative strides) only access the last element of the array, |
| 7 |
! as the access involves a pointer to array that is initialized to point |
| 8 |
! to the last element in the case of a reversed array. |
| 9 |
|
| 10 |
program main |
| 11 |
integer, dimension (2) :: idx, a, b |
| 12 |
a = (/ 3, 4 /) |
| 13 |
idx = (/ 1, 2 /) |
| 14 |
call check_values(a(idx(2:1:-1)), (/ 4, 3 /)) |
| 15 |
contains |
| 16 |
subroutine check_values(values, expected) |
| 17 |
integer, dimension(:) :: values, expected |
| 18 |
if (size(values) /= size(expected)) stop 1 |
| 19 |
if (any(values /= expected)) stop 2 |
| 20 |
end subroutine check_values |
| 21 |
end program main |