1! { dg-do run } 2! PR 47065 - make sure that impure functions are not evaluated twice when 3! replacing calls to trim with expression(1:len_trim) 4module foo 5 implicit none 6contains 7 function f() 8 integer :: f 9 integer :: s=0 10 s = s + 1 11 f = s 12 end function f 13end module foo 14 15program main 16 use foo 17 implicit none 18 character(len=10) :: line 19 character(len=4) :: b(2) 20 b(1) = 'a' 21 b(2) = 'bc' 22 write(unit=line,fmt='(A,A)') trim(b(f())), "X" 23 if (line /= "aX ") call abort 24 if (f() .ne. 2) call abort 25end program main 26