With the following code
module m_1 implicit none type t_1 integer i contains procedure, private :: t1_ass_i generic :: assignment(=) => t1_ass_i end type contains elemental subroutine t1_ass_i( var, expr ) class(t_1), intent(out) :: var integer, intent(in) :: expr var%i = expr end subroutine end module module m2 use m_1 implicit none type :: T_2 LOGICAL :: a_flag end type type:: T_3 type(t_1) :: a_date end type type :: T_4 end type type, public:: T_5 type(T_2) :: v_t2 type(T_3) :: v_t3 type(T_4) :: v_t4 end type end module program test use m2 implicit none type(T_5) :: a1, a2 a1%v_t2%a_flag = .true. a2 = a1 print *, a1%v_t2%a_flag print *, a2%v_t2%a_flag end program test
the result I expect is:
but we get:
the fact that commenting the line
type(T_4) :: v_t4
leads to the expected result makes me think this is a compiler bug, but I am not 100% of my interpretation of the standard re components with defined assignment.
I am currently using ifort v220.127.116.11 Build 20170411
I agree with you that this appears to be a compiler bug. Please report it via the Intel Online Service Center.
The standard says, for intrinsic assignment of derived types:
An intrinsic assignment where the variable is of derived type is performed as if each component of the variable
were assigned from the corresponding component of expr using pointer assignment for each pointer
component, defined assignment for each nonpointer nonallocatable component of a type that has a type-bound
defined assignment consistent with the component, intrinsic assignment for each other nonpointer nonallocatable
component, and intrinsic assignment for each allocated coarray component