------- Comment #5 from sfilippone at uniroma2 dot it 2010-08-24 12:50 ------- (In reply to comment #3) > Reduced test case: > > program bug20 > > type :: d_base_sparse_mat > integer :: v(10) = 0. > end type d_base_sparse_mat > > class(d_base_sparse_mat),allocatable :: a > > allocate (d_base_sparse_mat :: a) > > select type(aa => a) > type is (d_base_sparse_mat) > write(0,*) 'NV = ',size(aa%v) > class default > write(0,*) 'Not implemented yet ' > end select > > end program bug20 > > > Note: The double free only happens when an associate-name is used. > Changing the original example as follows: subroutine doit(a) type(d_sparse_mat), intent(in) :: a integer :: i , nv call doselect(a%a) end subroutine doit
subroutine doselect(aa) class(base_sparse_mat) :: aa select type(aa) type is (d_base_sparse_mat) nv = size(aa%v) write(0,*) 'NV = ',nv class default write(0,*) 'Not implemented yet ' end select end subroutine doselect makes it work. However, when the same change is applied to the original library, a double free pops up in another place, unrelated to this issue; this would indicate that there are other instances of some sort of flaw in the cleanup of temporaries. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45384