[Bug fortran/57697] [OOP] Segfault with defined assignment for components during intrinsic assignment
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 19 06:44:00 GMT 2013
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
More information about the Gcc-bugs
mailing list