| 1 |
! { dg-do compile } |
| 2 |
! { dg-additional-options "-fcheck=bounds -fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/104908 - incorrect out-of-bounds runtime error |
| 5 |
|
| 6 |
program test |
| 7 |
implicit none |
| 8 |
type vec |
| 9 |
integer :: x(3) = [2,4,6] |
| 10 |
end type vec |
| 11 |
type(vec) :: w(2) |
| 12 |
call sub(w) |
| 13 |
contains |
| 14 |
subroutine sub (v) |
| 15 |
class(vec), intent(in) :: v(:) |
| 16 |
integer :: k, q(3) |
| 17 |
q = [ (v(1)%x(k), k = 1, 3) ] ! <-- was failing here after r11-1235 |
| 18 |
print *, q |
| 19 |
end |
| 20 |
end |
| 21 |
|
| 22 |
subroutine sub2 (zz) |
| 23 |
implicit none |
| 24 |
type vec |
| 25 |
integer :: x(2,1) |
| 26 |
end type vec |
| 27 |
class(vec), intent(in) :: zz(:) ! used to ICE after r11-1235 |
| 28 |
integer :: k |
| 29 |
k = zz(1)%x(2,1) |
| 30 |
end |
| 31 |
|
| 32 |
! { dg-final { scan-tree-dump-times " above upper bound " 4 "original" } } |