(j3.2006) Question about 29113

Malcolm Cohen malcolm
Thu Oct 2 04:00:03 EDT 2014

>> No clairvoyance is needed,
>if you happen to have 11-210r1 or Malcolm's e-mail address handy...

I did not find it by remembering everything I've written over the last decade, 
but by
  grep "another Fortran" x3j3/m*/*.txt

>If we really need this,

Yes we really need this unless you want to write up an expanded feature request 
for next year's WG5 meeting.  Please do not do that.

> it would be helpful

Sure, it could be wordsmithed a bit to make it clearer.  No disagreement there. 
In fact it would probably be best to format it as Case (i), Case (ii), Case(iii) 
just like we do for separate cases in other intrinsics etc.

>Using only "is not the result of..." doesn't work because one might get
>the address of an array element using C_LOC, send it to a C function,
>which increments it, resulting in an address that's still the address of
>an element of the same array, and then returns it to Fortran.

Right, we are not going to delete the "in use by another Fortran entity" bit, 
which is what catches this and *many* other shenanigans.

>In any case, "in use by another Fortran entity" isn't quite what we

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.

>Maybe "shall not be the address of a Fortran entity" would work.

Better as is.

>Looking a bit more deeply at p3, why is FPTR required to be scalar?

p3 is a completely different topic.  It is required to be scalar *because that 
is what we voted to approve*.

>This prevents dragging a pointer assocociated with a noninteroperable
>array through a C function and thence into another Fortran subprogram.
>Did we really intend to prohibit this?

Yes.  Lots of Fortran arrays are not characterised simply by "address" or even 
"address + shape".  Layout info matters.

>  How about the case that the "C
>function" is actually an interoperable Fortran subprogram?

If you are writing purely in Fortran there is no need for C_PTR et al 
whatsoever.  Just use real Fortran pointers.

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

More information about the J3 mailing list