| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/61138 |
| 4 |
! Wrong code with pointer-bounds remapping |
| 5 |
! |
| 6 |
! Contributed by Tobias Burnus <[email protected]> |
| 7 |
|
| 8 |
implicit none |
| 9 |
integer, target :: tgt(10) |
| 10 |
integer, target, allocatable :: tgt2(:) |
| 11 |
integer, pointer :: ptr(:) |
| 12 |
|
| 13 |
tgt = [1,2,3,4,5,6,7,8,9,10] |
| 14 |
tgt2 = [1,2,3,4,5,6,7,8,9,10] |
| 15 |
|
| 16 |
|
| 17 |
ptr(-5:) => tgt(5:) ! Okay |
| 18 |
|
| 19 |
if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) STOP 1 |
| 20 |
if (any (ptr /= [5,6,7,8,9,10])) STOP 2 |
| 21 |
|
| 22 |
|
| 23 |
ptr(-5:) => tgt2(5:) ! wrongly associates the whole array |
| 24 |
|
| 25 |
print '(*(i4))', size(ptr), lbound(ptr) |
| 26 |
print '(*(i4))', ptr |
| 27 |
|
| 28 |
if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) STOP 3 |
| 29 |
if (any (ptr /= [5,6,7,8,9,10])) STOP 4 |
| 30 |
end |
| 31 |
|