This is the mail archive of the
mailing list for the GCC project.
Re: [Patch, fortran] PR80477 - [OOP] Polymorphic function result generates memory leak
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 28 Jul 2018 18:37:12 +0200
- Subject: Re: [Patch, fortran] PR80477 - [OOP] Polymorphic function result generates memory leak
- References: <CAGkQGi+6Cicx3SxKv-L1hLGPf9R+Rp0Wea2Cb9es7ok+VK2SnA@mail.gmail.com>
2018-07-28 9:32 GMT+02:00 Paul Richard Thomas <firstname.lastname@example.org>:
> Several attempts, including mine, were made to fix this bug since it
> was posted. They were all attacking the wrong place. Instead of
> providing the free of the class _data as part of the call to
> 'add_a_type' it should be included in the post block of the argument
> processing in the call to 'assign_a_type'. The comment in the patch
> says the rest.
> Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
great that you managed to solve this one! The patch looks very good to
me, but I'm afraid two details may be missing:
1) If the type has allocatable components, those need to be freed first.
2) If the type has a finalizer, that needs to be called as well.
I believe that both points can be fixed by calling the _final
component of the vtab before freeing the class data. Should not be
hard to add, I hope (gfc_add_finalizer_call might be useful).
Thanks for your efforts ...