PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / trim_optimize_4.f90
blob551489eb13b81dab733adf1c6a106ee27271ba80
1 ! { dg-do run }
2 ! PR 47065 - make sure that trim optimization does not lead to
3 ! wrong-code with aliasing.
4 ! Test case provided by Tobias Burnus.
5 program main
6 character(len=12) :: str
7 str = '1234567890'
8 call sub(trim(str), str)
9 ! Should print '12345 '
10 if (str /= '12345 ') STOP 1
11 call two(trim(str))
12 if (str /= '123 ') STOP 2
13 contains
14 subroutine sub(a,b)
15 character(len=*), intent(in) :: a
16 character(len=*), intent(out) :: b
17 b = ''
18 b = a(1:5)
19 end subroutine sub
20 subroutine two(a)
21 character(len=*), intent(in) :: a
22 str = ''
23 str(1:3) = a(1:3)
24 end subroutine two
25 end program main