Debian Codegraph @

gcc/testsuite/gfortran.dg/bounds_check_array_io.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=bounds -fdump-tree-original" }
3 !
4 ! PR fortran/117791 - crash with bounds check writing array section
5 ! Contributed by Andreas van Hameren (hameren at ifj dot edu dot pl)
6
7 program testprogram
8 implicit none
9 integer, parameter :: array(4,2)=reshape ([11,12,13,14 ,15,16,17,18], [4,2])
10 integer :: i(3) = [45,51,0]
11
12 write(*,*) 'line 1:',array(:, sort_2(i(1:2)) )
13 write(*,*) 'line 2:',array(:, 3 - sort_2(i(1:2)) )
14 write(*,*) 'line 3:',array(:, int (3 - sort_2(i(1:2))))
15
16 contains
17
18 function sort_2(i) result(rslt)
19 integer,intent(in) :: i(2)
20 integer :: rslt
21 if (i(1) <= i(2)) then
22 rslt = 1
23 else
24 rslt = 2
25 endif
26 end function
27
28 end program
29
30 ! { dg-final { scan-tree-dump-times "sort_2" 5 "original" } }
31 ! { dg-final { scan-tree-dump-not "_gfortran_transfer_array_write" "original" } }