When the rhs is polymorphic and allocated during assignment, the
derivedType might have change from the one set in toDerived.
Use the one set in the addendum so it is always up to date.
This can happen in cases like the one shown below:
type :: t1 end type t1 type, extends(t1) :: t2 integer, allocatable :: i(:) end type subroutine assign(t) class(t2), intent(in) :: t class(t1), allocatable :: cp cp = t end subroutine
Probably best to use:
so that it is obvious that toAddendum is not null, and the there is a good reason not to use toDerived.