2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / trim_optimize_4.f90
blob41c65b10bcde46a5de53ed39b6c22fc2576d1335
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 ') call abort
11 call two(trim(str))
12 if (str /= '123 ') call abort
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