2 ! Test the fix for PR26257, in which the implicit reference to
3 ! chararray in the main program call of chararray2string would
4 ! cause a segfault in gfc_build_addr_expr.
6 ! Based on the reduced testcase in the PR.
9 function chararray2string(chararray) result(text)
10 character(len=1), dimension(:) :: chararray ! input
11 character(len=size(chararray, 1)) :: text ! output
12 do i = 1,size(chararray,1)
13 text(i:i) = chararray (i)
15 end function chararray2string
17 program TestStringTools
19 character(len=52) :: txt
20 character(len=1), dimension(52) :: chararr = &
21 (/(char(i+64),char(i+96), i = 1,26)/)
22 txt = chararray2string(chararr)
23 if (txt .ne. "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz") &
25 end program TestStringTools
27 ! { dg-final { cleanup-modules "chtest" } }