[Bug fortran/88511] passing allocatable character through two levels of procedure calls fails
stephen at soliday dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 15 16:46:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88511
--- Comment #1 from Stephen Soliday <stephen at soliday dot com> ---
One of the respondents in Stack overflow posted this reduced version of my code
that also reproduces the segmentation fault.
program main
implicit none
character(:), allocatable :: txt
call sub1(txt)
print *, "main ", len(txt), txt ! prints: main 0 (or throws segfault)
contains
subroutine sub1(txt)
character(:), allocatable, optional, intent(out) :: txt
call sub2(txt)
print *, "sub1 ", len(txt), txt ! prints: sub1 0 (or throws segfault)
end subroutine sub1
subroutine sub2(txt)
character(:), allocatable, optional, intent(out) :: txt
if(present(txt)) txt = "message"
print *, "sub2 ", len(txt), txt ! prints: sub2 7 message
end subroutine sub2
end program main
More information about the Gcc-bugs
mailing list