(j3.2006) deallocating pointer function results
Mon Nov 9 15:18:22 EST 2015
On Mon, 2015-11-09 at 19:47 +0000, Bill Long wrote:
> On Nov 9, 2015, at 1:11 AM, Cohen Malcolm <malcolm at nag-j.co.jp> wrote:
> > No it does not make sense. The dummy argument (which *is* a name, thus
> > "name association") is associated with the effective argument, which is a
> > pointer, being the result of a function reference.
> > Thus "changes accordingly" would mean the result of the function reference
> > changes accordingly! Obviously nonsense, just the same as the nonpointer
> > case of assigning a value to a dummy associated with an actual argument of
> > "X+1?.
> So, the effective argument is a pointer. You seem to be saying that
> pointer cannot become disassociated. That seems like obvious nonsense
> to me. Pointers with the INTENT(IN) attribute have that restriction,
> but that is not the case here. Sure, when the procedure completes,
> that pointer will disappear, but that is not relevant. The effect of
> deallocating the dummy argument is to deallocate the target of the
> pointer that is the effective argument, and to mark both the dummy
> pointer and the effective argument pointer to disassociated. Simple.
> I don?t see how that has anything to do with the ?X+1? non-anology.
No matter what we think we believe the standard says, I'm coming around
to agree with this desire. Otherwise, using the result of a function
that returns a pointer result would result in a leak if that pointer was
allocated by the function and there is not another pointer associated
with the same target.
> I?m coming around to believe that the point of the inconsistency in
> the original program example was that the statement
> deallocate (pointer_valued_func_ref( ) )
> should be allowed, and the current text in the standard is too restrictive.
> Bill Long longb at cray.com
> Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9142
> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
> J3 mailing list
> J3 at mailman.j3-fortran.org
More information about the J3