https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69955
Bug ID: 69955 Summary: Memory leak with array constructor and derived type Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mrestelli at gmail dot com Target Milestone: --- The attached code leaks memory for me: $ gfortran --version GNU Fortran (GCC) 6.0.0 20160224 (experimental) program p implicit none type :: t1 real, allocatable :: x(:) end type t1 type :: t2 type(t1), allocatable :: ts(:) end type t2 integer :: i,j type(t2) :: var(100) do i=1,100 allocate(var(i)%ts(i)) do j=1,i allocate(var(i)%ts(j)%x(i+j)) enddo enddo do j=1,10000 ! change this to control the amount of leaked memory write(*,*) size( (/( var(i)%ts , i=1,size(var) )/) ) enddo do i=1,100 deallocate(var(i)%ts) enddo end program p