| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-fcheck=bounds -fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/119118 |
| 5 |
|
| 6 |
program main |
| 7 |
implicit none |
| 8 |
character(10) :: str = "1234567890" |
| 9 |
integer :: n = 3 |
| 10 |
|
| 11 |
print *, str(-1:-2) ! zero-length substring: OK |
| 12 |
|
| 13 |
print *, str(-1:n) ! 2 checked bounds |
| 14 |
print *, len (str(-1:n)) ! 2 checked bounds |
| 15 |
|
| 16 |
print *, str(-n:1) ! 1 checked bound / 1 eliminated |
| 17 |
print *, len (str(-n:1)) ! 1 checked bound / 1 eliminated |
| 18 |
|
| 19 |
print *, str(-n:11) ! 2 checked bounds |
| 20 |
print *, len (str(-n:11)) ! 2 checked bounds |
| 21 |
|
| 22 |
print *, str(-n*n%kind:sum(n-[0,n%kind])) ! 2 checked bounds |
| 23 |
|
| 24 |
end program main |
| 25 |
|
| 26 |
! { dg-final { scan-tree-dump-times "Substring out of bounds:" 12 "original" } } |