Hi again,
For the code below, I get an ICE, caused the interface assignment(=) block.
module mod1 type, public :: t1 character(:), allocatable :: chars end type interface assignment(=) module procedure ASSIGN_t1, ASSIGN_t1_chars, ASSIGN_chars_t1 end interface contains subroutine bad_way(t, array) type(t1), allocatable, intent(OUT) :: t(:) character(*), intent(IN) :: array(:) integer :: i, j allocate (t(1:0)) do i = 1, SIZE(array) t = [t, t1()] j = SIZE(t) t(j)%chars = array(i) enddo end subroutine !---------------------------------------------------------------------------------------------- elemental subroutine ASSIGN_t1(lhs, rhs) class(t1), intent(OUT) :: lhs class(t1), intent(IN) :: rhs continue if (ALLOCATED(rhs%chars)) then lhs%chars = rhs%chars else lhs%chars = '' endif end subroutine !---------------------------------------------------------------------------------------------- elemental subroutine ASSIGN_t1_chars(lhs, char2) class(t1), intent(OUT) :: lhs character(*), intent(IN) :: char2 continue lhs%chars = char2 end subroutine !---------------------------------------------------------------------------------------------- elemental subroutine ASSIGN_chars_t1(char1, rhs) character(*), intent(OUT) :: char1 class(t1), intent(IN) :: rhs continue if (ALLOCATED(rhs%chars)) then char1 = rhs%chars else char1 = '' endif end subroutine end module mod1
The ICE goes away by either using TYPE instead of CLASS in the ASSIGN_* subroutines, or using MOVE_ALLOC to reallocate t.