http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57697

--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Still doesn't correctly work as the following code shows:

        if (_F.DA0 == 0B)
            _F.DA0 = left;
        …
    finally
      {
        if (left != 0B)
            __builtin_free ((void *) left);
        if (_F.DA0 != 0B)
            __builtin_free ((void *) _F.DA0);

Which causes a double free!

module m0
  implicit none
  type component
    integer :: i = 42
  contains
    procedure :: assign0
    generic :: assignment(=) => assign0
  end type
  type parent
    type(component) :: foo
  end type
contains
  elemental subroutine assign0(lhs,rhs)
    class(component), intent(INout) :: lhs
    class(component), intent(in) :: rhs
    lhs%i = 20
  end subroutine
end module

program main
  use m0
  implicit none
  block
    type(parent), allocatable :: left
    type(parent) :: right
    print *, right%foo
    left = right
    print *, left%foo
    if (left%foo%i /= 20) call abort()
  end block
end

Reply via email to