When compiled with the “-g” option the following example seg faults on the sourced allocation statement. Interestingly, the code runs correctly without the “-g” option, however valgrind still shows bad/questionable things going on in the pgi runtime library.
This is with the new 18.10 community edition on 64-bit Linux.
The example is extracted from a unit test from GitHub - nncarlson/yajl-fort: YAJL-Fort: A modern Fortran interface to the YAJL library
type, abstract :: json_value
end type
type, extends(json_value) :: json_string
character(:), allocatable :: value
end type
class(json_value), allocatable :: x
call foo('fubar', x)
select type (x)
type is (json_string)
if (x%value /= 'fubar') stop 1
class default
stop 2
end select
contains
subroutine foo(string, x)
character(*), intent(in) :: string
class(json_value), allocatable, intent(out) :: x
allocate(x, source=json_string(string)) ! <== SEG FAULTS HERE
end subroutine
end