This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32665] allocatable array on lhs deleted while still in use on rhs
- From: "pault at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jul 2007 09:50:48 -0000
- Subject: [Bug fortran/32665] allocatable array on lhs deleted while still in use on rhs
- References: <bug-32665-13648@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pault at gcc dot gnu dot org 2007-07-13 09:50 -------
This is a two-in-oner; as well as the deallocation, this is broken:
$ cat pr32665.f90
TYPE :: x
INTEGER, ALLOCATABLE :: a(:)
END TYPE
TYPE(x) :: a, b
call foo
b = x((/ (a%a), 4 /))
print *, "foo gives ", b%a
call bar
b = x((/ (a%a), 4 /))
print *, "bar gives ", b%a
contains
subroutine foo
allocate (a%a(2))
a%a(1) = 1
a%a(2) = 2
end subroutine
subroutine bar
a = x ((/1, 2/))
end subroutine
end
$ ./a
foo gives 1 2 4
bar gives 1 2 0 4
This comes about because the structure constructor suddenly runs amok, with:
parm.2.data = 0B;
x.0.a.offset = 0;
x.0.a.dim[0].ubound = x.0.a.dim[0].ubound + 1;
x.0.a.dim[0].lbound = 1;
D.1014 = x.0.a.dim[0].lbound * x.0.a.dim[0].stride;
x.0.a.offset = x.0.a.offset - D.1014;
}
a = x.0;
*sigh*
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32665