Segfault on polymorphic sourced allocation

I’d like to report a compiler bug with 18.4. The following example gives a run time segfault on the sourced allocation statement. Running under valgrind shows some issues in pgf90_poly_asn. Here are the first couple:

==24369== Conditional jump or move depends on uninitialised value(s)
==24369== at 0x52967B1: pgf90_get_object_size (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x529805A: sourced_alloc_and_assign (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x5296EE6: pgf90_poly_asn (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x40102D: MAIN_ (pgi-20180505a.f90:10)
==24369==
==24369== Use of uninitialised value of size 8
==24369== at 0x52967BB: pgf90_get_object_size (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x529805A: sourced_alloc_and_assign (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x5296EE6: pgf90_poly_asn (in /opt/pgi/linux86-64/18.4/lib/libpgf90.so)
==24369== by 0x40102D: MAIN_ (pgi-20180505a.f90:10)


type, abstract :: json_value
end type
  
type, extends(json_value) :: json_string
  character(:), allocatable :: value
end type

class(json_value), allocatable :: a

allocate(a, source=json_string('foo'))  ! SEGFAULT HERE
select type (a)
type is (json_string)
  if (.not.allocated(a%value)) stop 21
  if (a%value /= 'foo') stop 22
class default
  stop 20
end select

end

Thanks NeilC!

While I wasn’t able to recreate the seg fault with this code, I do see the valgrind errors. I have added a problem report (TPR#25600) and sent it to engineering for further investigation.

Best Regards,
Mat

FYI for those encountering a similar issue, it has been resolved in PGI 19.9