https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92178

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Oct 22, 2019 at 10:22:42PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> --- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> On Tue, Oct 22, 2019 at 09:30:14PM +0000, sgk at troutmask dot
> apl.washington.edu wrote:
> > 
> > Cutting the -ftree-dump-original down to the 'call' statement
> > gives
> > 
> > MAIN__ ()
> > {
> >     {
> >       integer(kind=4) D.3955;
> >       integer(kind=4) D.3956;
> >       integer(kind=4) M.7;
> > 
> >       D.3955 = (*(integer(kind=4)[0:] * restrict) a.data)[a.offset + 1];
> >       D.3956 = D.3955 * D.3955;
> >       M.7 = D.3956;
> >       M.7 = MIN_EXPR <M.7, 0>;
> >       if ((integer(kind=4)[0:] * restrict) a.data != 0B)
> >         {
> >           __builtin_free ((void *) a.data);
> >           (integer(kind=4)[0:] * restrict) a.data = 0B;
> >         }
> >       assign (M.7, &a);
> >     }
> > }
> > 
> > which shows the argument evaluation is done correctly.  In short,
> > gfortran needs to scan the effective and dummy arguments for a
> > deallocation and just do the right thing.
> > 
> 
> The evaluation of arguments seems to be done in trans-expr.c
> gfc_conv_procedure_call(), where the argument list is simply
> walked and evaluated.  That's not good as this pr shows. :(
> 

There is a massive for-loop (lines: 5478-6638) that is used
for the evaluation of arguments.  Within those lines, the
blocks 5924-5981, 6071-6111, and 6242-6273 are used to 
delete allocated actual args for intent(out) dummy args.

I suspect that those blocks need to be removed, and second
following for-loop should scan the arg list to do the
deallocations.

Reply via email to