[Patch, fortran] PR48351 - [OOP] Realloc on assignment fails if parent component is CLASS

Paul Richard Thomas paul.richard.thomas@gmail.com
Fri Jan 13 15:29:00 GMT 2012


Dear All,

When the only modification was to set the attribute alloc_comp for
class containers, I was going to commit this patch as obvious.
However, it caused a regression in class-19.f03 by increasing the
count of BUILTIN_FREE from 11 to 23!  Whilst the extra calls did no
harm, this offended my sensibilities excessively :-)  The fix to
trans-array.c (structure_alloc_comps) is a bit more invasive, so I
thought that I had better come to the list for approval.  Note that
this 'bug'  applied to other cases and was the cause of the
proliferation of free's in allocatable_scalar_9.f90.  I have checked
the code for this case and everything that should be freed is
freed.... just once .

Bootstrapped and regtested on i686/Ubuntu10.04 - OK for trunk?

Paul

2012-01-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/48351
	* trans-array.c (structure_alloc_comps): Suppress interative
	call to self, when current component is deallocated using
	gfc_trans_dealloc_allocated.
	* class.c (gfc_build_class_symbol): Copy the 'alloc_comp'
	attribute from the declared type to the class structure.

2012-01-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/48351
	* gfortran.dg/alloc_comp_assign.f03: New.
	* gfortran.dg/allocatable_scalar_9.f90: Reduce count of
	__BUILTIN_FREE from 38 to 32.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr48351.diff
Type: text/x-patch
Size: 7837 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120113/2cca355c/attachment.bin>


More information about the Gcc-patches mailing list