This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/60922] [4.9/5 regression] Memory leak with allocatable CLASS components
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Jan 2015 16:43:30 +0000
- Subject: [Bug fortran/60922] [4.9/5 regression] Memory leak with allocatable CLASS components
- Auto-submitted: auto-generated
- References: <bug-60922-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60922
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #9 from janus at gcc dot gnu.org ---
Looking at the dump of the finalizer function (__final_test_leak_D_vect_type)
shows that it indeed has code to free the component v:
if (fini_coarray)
{
{
integer(kind=4) stat.5;
if (ptr->v._data == 0B)
{
stat.5 = 1;
}
else
{
if (ptr->v._vptr->_final != 0B)
{
{
struct array0_d_base_vect_type desc.6;
desc.6.dtype = 40;
desc.6.data = (void * restrict) ptr->v._data;
ptr->v._vptr->_final (&desc.6, ptr->v._vptr->_size, 0);
}
}
__builtin_free ((void *) ptr->v._data);
stat.5 = 0;
}
However, it is guarded by the check for 'fini_coarray', which is the third
argument of the finalizer function and is being set to zero on invocation:
x._vptr->_final (&desc.8, x._vptr->_size, 0);
The documentation of 'generate_finalization_wrapper' in class.c says:
If "fini_coarray" is false, coarray components are not finalized to allow for
the correct semantic with intrinsic assignment.
So I guess it should only apply to COARRAY components, not to CLASS components.
Tobias: I guess you were the one who implemented it. Could you please comment
on this?