http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57696
Bug ID: 57696 Summary: Defined assignment for components not used when those are ALLOCATABLE Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: pault at gcc dot gnu.org The following prints 42 42 with gfortran and 42 20 with crayftn. Thus, gfortran does not use defined assignment - but it should. Note: If "right%foo" is not allocated, the code segfaults with crayftn. module m0 implicit none type component integer :: i = 42 contains procedure :: assign0 generic :: assignment(=) => assign0 end type type parent type(component), allocatable :: foo end type contains elemental subroutine assign0(lhs,rhs) class(component), intent(INout) :: lhs class(component), intent(in) :: rhs lhs%i = 20 end subroutine end module program main use m0 implicit none type(parent) :: left, right allocate(right%foo) print *, right%foo left = right print *, left%foo end