I am looking for some advice with the following assignment to the selector variable in a SELECT TYPE block.
The Intel compiler 13.1.3 compiles successfully, but version 14.0.1 produces a run-time error (see below):
program p implicit none ! abstract type, abstract :: abstract_type integer :: nonempty end type ! contains abstract allocatable type :: container_type integer :: nonempty ! fix: uncomment next line or use pointer instead class(abstract_type), allocatable :: abstract_field end type type(container_type) :: rhs class(container_type), allocatable :: polymorphic_lhs ! assign into polymorphic select type (polymorphic_lhs) type is (container_type) ! runtime error (ifort 14.0.1) ! problem with 'abstract_field' allocatable component ! (no matter it's allocation status in lhs and rhs) polymorphic_lhs = rhs end select ! output (ifort 13.1.3): F print *, allocated(polymorphic_lhs%abstract_field) end program
Compilation and output:
$ ifort -g -O0 test.f90
forrtl: severe (122): invalid attempt to assign into a pointer that is not associated
My two questions here are:
- Do I violate some restrictions (read-only variable in the SELECT CASE association or something) here?
- How else can I achieve the desired assignment in the case where 'polymorphic_lhs' is a PASS'ed derived type dummy argument?
Thanks for any comments!
With regards, Ferdinand