(j3.2006) Question about 29113

Malcolm Cohen malcolm
Fri Oct 3 01:52:19 EDT 2014

It is not gratuitous, it is by design.

You cannot call malloc multiple times and say "oh I wanted the same memory 
back".  You get one chance to assign the result of malloc to a pointer, then you 
have to use that pointer.  It's the same idea here.  You get your C address back 
from the C function and then you create ONE Fortran pointer for the object; any 
further manipulations must be based on that Fortran pointer, otherwise the 
floodgates are open to all kinds of aliasing with broken types.

Changing the design to do additional things is absolutely not in the remit of 
integration.  There is nothing broken here to fix.

As for
   Why cannot we replace "not in use by another Fortran entity" with "not
   the C address of a Fortran entity"?
because that achieves PRECISELY NOTHING.  Your example is STILL illegal because 
by the time of the second call it *IS* the C address of a Fortran entity (that 
being the target of the Fortran pointer).

And I should hope so too.  Your example is supposed to be disallowed.


-----Original Message----- 
From: Van Snyder
Date: ?? 26?10?3? 5:05
To: j3 at mailman.j3-fortran.org
Subject: Re: (j3.2006) Question about 29113

On Thu, 2014-10-02 at 17:00 +0900, Malcolm Cohen wrote:
> >In any case, "in use by another Fortran entity" isn't quite what we
> >want,
> It very much is what we want.
> > since thereby one cannot do the following (perhaps spread over
> >several scoping units):
> >
> > call c_f_pointer ( cptr, fptr1 )
> > ...
> > call c_f_pointer ( cptr, fptr2 )
> Right.  Don't do that.  It is not conforming.  This is a minimal
> extension to
> allow a particular case.

This gratuitous prohibition, that is not helpful, is potentially

If you have a program larger than a trivial one, developed by several
teams, including software for which you do not have source, and a
contractual obligation to remove all extensions and nonconformances, and
a processor detects this at runtime ten years after the software is
deployed, the expense, for no benefit, could be substantial.

Why cannot we replace "not in use by another Fortran entity" with "not
the C address of a Fortran entity"?

This is not a new feature request.  This is an integration issue of the
category that we promised to repair on page v of N1904.

J3 mailing list
J3 at mailman.j3-fortran.org

This e-mail has been scanned for all viruses by Star.

................................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list