https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63640
Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Joost.VandeVondele at mat dot ethz | |.ch --- Comment #1 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> --- this rather is a misunderstanding, allocatables are not necessarily freed at the end of the main program. For example this is leak free: > cat PR63640.f90 subroutine testmv3 type bar integer, allocatable :: ia(:), ja(:) end type integer, allocatable :: ia(:), ja(:) type(bar), allocatable :: sm,sm2 allocate(sm) allocate(sm2) allocate(sm%ia(100),sm%ja(100)) allocate(sm2%ia(1000),sm2%ja(1000)) allocate(ia(100),ja(1000)) call move_alloc(ja,ia) call move_alloc(sm%ia,sm2%ia) call move_alloc(sm%ja,sm2%ja) end subroutine testmv3 call testmv3 END BTW, to check for leaks, you can now use the following way to compile your code: gfortran -fsanitize=leak PR63640.f90 without the need to run under valgrind.