https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721
Bug ID: 67721 Summary: deep copy missing when assigning a derived type constructor to an array Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mikael at gcc dot gnu.org Target Milestone: --- In the following test, the assignment to v does a shallow copy of the rhs, so that the c2 components are shared among array elements. Then, any change made to one array element also impacts the other elements. ! { dg-do run } ! ! Check that scalar to array assignments of derived type constructor ! deep copy the value when there are allocatable components. program p implicit none type :: t1 integer :: c1 end type t1 type :: t2 type(t1), allocatable :: c2 end type t2 block type(t2) :: v(4) v = t2(t1(3)) v(2)%c2%c1 = 7 v(3)%c2%c1 = 11 v(4)%c2%c1 = 13 if (v(1)%c2%c1 /= 3) call abort if (v(2)%c2%c1 /= 7) call abort if (v(3)%c2%c1 /= 11) call abort if (v(4)%c2%c1 /= 13) call abort end block end program p