https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66079
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 35555 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35555&action=edit Initial fix This is a partial fix, in that it deals with the initial problem. type subdata integer, allocatable :: b endtype block call newRealVec end block contains subroutine newRealVec type(subdata), allocatable :: d, e, f allocate(d,source=subdata(1)) ! was lost, now OK allocate(e,source=d) ! OK allocate(f,source=create (99)) ! 8 bytes go AWOL if (d%b .ne. 1) call abort if (e%b .ne. 1) call abort if (f%b .ne. 99) call abort f = create (42) ! another 8 bytes go AWOL print *, f%b end subroutine function create (arg) result(res) integer :: arg type(subdata), allocatable :: res allocate(res, source = subdata(arg)) end function end The function calls are losing the allocation for the subdata type itself. The b component is correctly dealt with. I know what has to be done to fix this. Arrays are a mess. allocate (d(2), source = subdata ()) ICEs on a double free allocate (d(2), source = [subdata (1), subdata (2)]) loses 8 bytes in two chunks. Watch this space. Paul
