(j3.2006) type(C_ptr) and PURE

Tobias Burnus burnus
Mon Feb 11 08:11:54 EST 2013


The following is based on a recent posting by Thomas Jahns to 
comp.lang.fortran.

Namely, whether it is valid to assign a type(C_ptr) compontent of an 
intent(in) dummy argument to some other variable. I do not see a 
violation to C1283, thus, doing so seems to be valid. The question is 
whether it should be valid.

Tobias

PS: Test code by Thomas Jahns. (At least one compiler rejects it with 
"implicit pointer assignment from B".)

PROGRAM foo
   USE iso_c_binding, ONLY: c_ptr
   TYPE, BIND(c) :: bar
     TYPE(c_ptr) :: p
   END TYPE bar
CONTAINS
   ELEMENTAL FUNCTION bar_f2c(b) RESULT(p)
     TYPE(bar), INTENT(in) :: b
     TYPE(c_ptr) :: p
     p = b%p
   END FUNCTION bar_f2c
END PROGRAM foo




More information about the J3 mailing list