5 ! Failed to compile (segfault) with -fwhole-file.
6 ! Cf. PR 40873 comment 24; test case taken from
7 ! PR fortran/31867 comment 6.
10 pure
integer function lensum (words
, sep
)
11 character (len
=*), intent(in
) :: words(:), sep
12 lensum
= (size (words
)-1) * len (sep
) + sum (len_trim (words
))
18 pure
integer function lensum (words
, sep
)
19 character (len
=*), intent(in
) :: words(:), sep
23 function join (words
, sep
) result(str
)
24 ! trim and concatenate a vector of character variables,
25 ! inserting sep between them
26 character (len
=*), intent(in
) :: words(:), sep
27 character (len
=lensum (words
, sep
)) :: str
37 str
= trim (str
) // sep
// words(i
)
43 use util_mod
, only
: join
45 character (len
=5) :: words(2) = (/"two ","three"/)
46 write (*,"(1x,'words = ',a)") "'"//join (words
, "&")//"'"
49 ! { dg-final { cleanup-modules "util_mod" } }