https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87625
Bug ID: 87625 Summary: [OOP] (re)allocate on assignment fails for polymorphic array Product: gcc Version: 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 Target Milestone: --- I believe the following code should work and (re)allocate "var" when it gets assigned a constructor. However, there is no memory allocation done at all. It looks as if the allocatable attribute is not correctly checked for for "CLASS" variables. [If one manually allocates the variable, it works. As it does if one uses TYPE instead of CLASS.] implicit none type t integer :: i end type t class(t), allocatable :: var(:) call poly_init() print *, var(:)%i if (var(1)%i /= 11 .or. var(2)%i /= 12) call abort() contains subroutine poly_init() !allocate(var(2)) var = [t :: t(11), t(12)] end subroutine poly_init end