(j3.2006) INTENT(IN) C_PTR dummy argument of a PURE function

John Reid John.Reid
Mon Oct 26 12:02:48 EDT 2015


J3,

Here is an issue that J3 has discussed. Was it ever resolved?

Is this code standard conforming?

     PURE FUNCTION bar_f2c(b) RESULT(p)
       USE iso_c_binding
       TYPE(c_ptr), intent(in) :: b
       TYPE(c_ptr) :: p
       p = b
     END FUNCTION bar_f2c

ifort and gfortran do not fault it, but NAG does because of "Implicit 
pointer assignment from B".

C1283 in 10-007r1 says:

In a pure subprogram  ... a dummy argument with the INTENT (IN) 
attribute, ... shall not be used
...
(2) as the data-target in a pointer-assignment-stmt ,
...
(4) as the expr of an intrinsic assignment statement in which the 
variable is of a derived type if the derived type has a pointer 
component at any level of component selection,
...

The above code seems to break the spirit of the above rules but not the 
letter. I think (4) should read

(4) as the expr of an intrinsic assignment statement in which the 
variable is of a derived type if the derived type is C_PTR, C_FUNPTR, 
or has a pointer component at any level of component selection,

Cheers,

John.



More information about the J3 mailing list