[Bug fortran/60922] [4.9/5 regression] Memory leak with allocatable CLASS components

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jan 17 16:26:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60922

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.9/5 regression]  Memory  |[4.9/5 regression] Memory
                   |leak with INTENT(OUT) CLASS |leak with allocatable CLASS
                   |argument w/ allocatable     |components
                   |CLASS components            |

--- Comment #8 from janus at gcc dot gnu.org ---
As comment 7 shows, the problem is not specific to intent(out) arguments but
can occur also in other contexts where deallocation/finalization should occur.

The following test case demonstrates the same leak with an auto-deallocated
local variable (again leaks with 4.9 and trunk, but not 4.8):


program test_leak
  implicit none

  type d_base_vect_type
  end type

  type d_vect_type
    class(d_base_vect_type), allocatable :: v
  end type

  call test()

contains

  subroutine test()
    class(d_vect_type), allocatable :: x
    allocate(x)
    allocate(x%v)
    print *,"allocated!"
  end subroutine

end



More information about the Gcc-bugs mailing list