[Patch, fortran] PR32665 - allocatable array on lhs deleted while still in use on rhs
Paul Richard Thomas
paul.richard.thomas@gmail.com
Mon Jul 16 09:43:00 GMT 2007
:ADDPATCH fortran:
This turns out to be a double problem, one of which also appears as PR31320.
(i) An array constructor, used as an argument in the constructor of a
structure with allocatable components, yielded incorrect bounds for
the allocatable component. This manifests itself as memory leaks, bad
accesses and segfaults at runtime (PR31320).
(ii) The dependency between the rhs and lhs, where the lhs appears as
a reference in its own constructor, led to an ICE because the array
was deallocated at the start of the assignment.
The ChangeLog gives a description of the cure. Note that I took the
opportunity to fix some whitespace problems, which makes the patch
look more substantial than it actually is.
Regtested on Cygwin_NT/amd64 - does not break cp2k - OK for trunk?
Paul
2007-07-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31320
PR fortran/32665
* trans-expr.c (gfc_trans_subcomponent_assign): Ensure that
renormalization unity base is done independently of existing
lbound value.
(gfc_trans_scalar_assign): If rhs is not a variable, put
lse->pre after rse->pre to ensure that de-allocation of lhs
occurs after evaluation of rhs.
2007-07-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31320
PR fortran/32665
* gfortran.dg/alloc_comp_constructor_3.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr32665.diff
Type: application/octet-stream
Size: 7304 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070716/503f9c24/attachment.obj>
More information about the Fortran
mailing list