https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98573
--- Comment #3 from David Neill Asanza <davidhneill at gmail dot com> --- A related case when the array is 0-length. In this case, the dynamic type is lost in both assignment and sourced allocation. $ cat type_lost_0_length.f90 module foo type, public:: box class(*), allocatable :: val(:) end type contains subroutine store1(this, val) class(box), intent(out) :: this class(*), intent(in) :: val(:) this%val = val end subroutine store1 subroutine store2(this, val) class(box), intent(out) :: this class(*), intent(in) :: val(:) allocate(this%val, source=val) end subroutine store2 subroutine vector_type(val) class(*), intent(in) :: val(:) select type (val) type is (integer) print '("INTEGER")' class default print '("OTHER")' end select end subroutine vector_type end module foo program prog use foo type(box) :: b integer, allocatable :: arr1(:) integer, dimension(0) :: arr2 allocate(arr1(0)) call store1(b, arr1) call vector_type(b%val) ! OTHER call store2(b, arr1) call vector_type(b%val) ! OTHER call store1(b, arr2) call vector_type(b%val) ! OTHER call store2(b, arr2) call vector_type(b%val) ! OTHER end program $ gfortran -g -Wall -Wextra type_lost_0_length.f90 $ ./a.out OTHER OTHER OTHER OTHER