This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49466] [4.6/4.7 Regression] Memory leak with assignment of extended derived types
- From: "townsend at astro dot wisc.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 19 Jun 2011 18:57:45 +0000
- Subject: [Bug fortran/49466] [4.6/4.7 Regression] Memory leak with assignment of extended derived types
- Auto-submitted: auto-generated
- References: <bug-49466-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49466
--- Comment #6 from Rich Townsend <townsend at astro dot wisc.edu> 2011-06-19 18:57:40 UTC ---
(In reply to comment #5)
> > In the first assignment b.U is allocated, in the second assignment it is not
> > freed, before being allocated again.
>
> I don't think it should be freed then allocated for the second assignment in
> the code in comment#4.
Certainly, given that the lhs array component is the same shape as the rhs
array component, an optimization would be not to free and then allocate the
array prior to the copy.
However, that doesn't alter the fact that the behavior should be *as if* the
lhs array component were freed and then allocated with the appropriate shape.
This behavior has been in Fortran since TR 15581, which first introduced
allocatable derived-type components as an extension to Fortran 95.