This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR32665 - allocatable array on lhs deleted while still in use on rhs


: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.

Attachment: pr32665.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]