https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97123
Bug ID: 97123 Summary: double free detected in tcache 2 with recursive allocatable type Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: igor.gayday at mu dot edu Target Milestone: --- Consider the following program: program test_prg implicit none type :: recursive_block type(recursive_block), allocatable :: subblocks(:, :) end type type(recursive_block) :: top_level top_level = init_recursive() deallocate(top_level % subblocks) contains function init_recursive() result(res) type(recursive_block) :: res type(recursive_block), allocatable :: inner(:, :) allocate(inner(1, 1)) allocate(inner(1, 1) % subblocks(1, 1)) res % subblocks = inner end function end program Compiled with gfortran 10.2, it crashes at runtime on deallocate(top_level % subblocks) with the following message: free(): double free detected in tcache 2