[Patch, Fortran, OOP] PR 47637: Memory leak involving INTENT(OUT) CLASS argument w/ allocatable components

Janus Weil janus@gcc.gnu.org
Wed Feb 9 13:11:00 GMT 2011


Hi Paul,

thanks for the review!

> It looks OK but for one thing.  Are we guaranteed that tmp =
> CLASS_DATA (f->sym)->backend_decl is present?

I would argue that, if "f->sym->backend_decl" is present (which seems
to be the case), then also "CLASS_DATA (f->sym)->backend_decl" should
be present.

CLASS_DATA simply returns the symbol's first component, which for
class containers is the _data component. (This does not involve any
vtable symbols.)


> Should we not check and do the following:
>
> /* Ensure that the vtable is completed.  */
> if (CLASS_DATA (f->sym)->backend_decl == NULL_TREE)
>  gfc_get_symbol_decl (f->sym);
> tmp = CLASS_DATA (f->sym)->backend_decl;
>    ?
>
> Or is this impossible?

Based on the above reasoning I'd say it's impossible (so that the
extra check is not needed).

If you agree, I'll commit the patch as is.

Cheers,
Janus



> On Wed, Feb 9, 2011 at 11:26 AM, Janus Weil <janus@gcc.gnu.org> wrote:
>> Hi all,
>>
>> here is a small patch which takes care of auto-deallocating
>> INTENT(OUT) CLASS arguments with allocatable components. Regtested on
>> x86_64-unknown-linux-gnu. Ok for trunk?
>>
>> Cheers,
>> Janus
>>
>>
>> 2011-02-09  Janus Weil  <janus@gcc.gnu.org>
>>
>>        PR fortran/47637
>>        * trans-decl.c (init_intent_out_dt): Handle CLASS arguments.
>>
>>
>> 2011-02-09  Janus Weil  <janus@gcc.gnu.org>
>>
>>        PR fortran/47637
>>        * gfortran.dg/auto_dealloc_2.f90
>>
>
>
>
> --
> The knack of flying is learning how to throw yourself at the ground and miss.
>        --Hitchhikers Guide to the Galaxy
>



More information about the Fortran mailing list