J3/03-120 To: J3 From: UK Fortran panel Subject: Edits for UK comment MTC11 (Separate C data & procedure pointers) Date: 11 February 2003 Comment MTC11 of the UK vote was: Have separate types for C data and procedure pointers. Function C_LOC operates on either pointers or functions. In C, pointers and functions are separate and it is confusing to mix them in Fortran. There should be a separate type C_FUNPTR for C function pointers. Here are the edits for this: 381:14. Change "C_PTR and C_NULL_PTR" to "C_PTR, C_FUNPTR, C_NULL_PTR and C_NULL_FUNPTR". 382:9 Replace the line by "The entities C_PTR and C_FUNPTR are described in 15.2.2.". 382:11. Add to end of paragraph "The entity C_NULL_FUNPTR shall be a named constant of type C_FUNPTR. The value of C_FUNPTR shall be that of a null pointer to a function." {We could come right out and say something like "(int (*)(void))0", but that seems unnecessary.} 383:2+. Change to [really an edit to 03-105r1] <> If X is a procedure, scalar of type C_FUNPTR; otherwise, scalar of type C_PTR. 383:16. Change "C_PTR" to "C_PTR or C_FUNPTR". 383:17. Change "type C_PTR" to "the same type as C_PTR_1". 384:5. Change "C_PTR" to "C_PTR or C_FUNPTR". 384:6. Append "FPTR shall be a procedure pointer if and only if CPTR is of type C_FUNPTR." {Alternatively and equivalently, "FPTR shall be a data pointer if and only if CPTR is of type C_PTR.". Specifying that procedureness must match seems better than specifying that dataness must match.} 384:6+1-2. Change the sentences "If SHAPE is present ... shall be present" to "SHAPE shall be present if and only if CPTR is of type C_PTR and FPTR is an array; its size shall be equal to the rank of FPTR." {As currently written, one is allowed to specify a SHAPE of zero size when FPTR is scalar. This is useless: it provides no functionality, makes errors more likely, and inhibits error detection.} 386:2-3. Replace by C_PTR and C_FUNPTR shall be derived types with private components or shall be type alias names. C_PTR is interoperable with any C object pointer type. C_FUNPTR is interoperable with any C function pointer type. 386:3+2. Change "required to have the same representation method for all C pointer types" to "required to have the same representation method for all C object pointer types and the same representation method for all C function pointer types". 386:3+6-7. Change "The function ... is interoperable" to "The function C_LOC can be used to return a value of type C_PTR that is the C address of an allocated allocatable variable or a value of type C_FUNPTR that is the C address of a procedure. The returned value is interoperable" {"value" is the correct term for the result of a function; entity is unnecessarily vague - C_LOC does not return a POINTER to a TYPE(C_PTR), it returns a value of TYPE(C_PTR).} 386:3+10. Change "C_PTR" to "C_FUNPTR or C_PTR".