| 1 |
! { dg-do run } |
| 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. |
| 5 |
! |
| 6 |
! Based on the reduced testcase in the PR. |
| 7 |
module chtest |
| 8 |
contains |
| 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) |
| 14 |
end do |
| 15 |
end function chararray2string |
| 16 |
end module chtest |
| 17 |
program TestStringTools |
| 18 |
use chtest |
| 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") & |
| 24 |
STOP 1 |
| 25 |
end program TestStringTools |