Bad assignment of DT with class(*) allocatable component

I’d like to report a bug in 18.4. In the following example the intrinsic assignment of derived type variables with a class(*) allocatable component is not being done correctly. The program should exit without any output (at the END statement) but instead exits early at an error check (STOP statement)

$ pgfortran pgi-dt-asn-1.f90
$ ./a.out
22


type foo
  class(*), allocatable :: val
end type
type(foo) :: x, y

allocate(x%val, source=42)
if (.not.allocated(x%val)) stop 11
select type (val => x%val)
type is (integer)
  if (val /= 42) stop 12
class default
  stop 13
end select

y = x ! THIS INTRINSIC ASSIGNMENT IS NOT EXECUTED CORRECTLY
if (.not.allocated(y%val)) stop 21
select type (val => y%val)
type is (integer)
  if (val /= 42) stop 22  ! EXITS HERE
class default
  stop 23
end select
end

Hi NeilC,

I was able to reproduce this issue here and have created TPR#25694 and sent to engineering for further investigation.

Thanks!
Mat