J3/14-235 To: J3 From: Van Snyder Subject: Unclear and incomplete FPTR specification in C_F_POINTER Date: 2014 September 26 Reference: 14-007r2 1. Discussion ============= In 15.2.3.3, in the third paragraph of the description of FPTR at [445:21-23], 14-007r2 says "in this case, X or its target if it is a pointer shall not have been deallocated or become undefined due to execution of a RETURN or END statement...." This needs some commas to assist parsing "X or its target if it is a pointer", and more importantly, a comma after "deallocated" to make it clear that any deallocation is prohibited, not just deallocation due to execution of a RETURN or END statement, or indeed by execution of a DEALLOCATE statement. What's wrong with associating a pointer with an object that has an undefined value? Perhaps the purpose of the association is to give it a value. There are deeper problems with the definition of the association status of FPTR (and some of them existed prior to 2008 or TS 29113). In 15.2.3.3, in the fourth paragraph of the description of FPTR at [445:27-446:1], 14-007r2 says "The storage sequence ... shall not be in use by any other Fortran entity...." This came from clause 9.9 of N1904, the DTS ballot for TS 29113. What does that mean? That it cannot be the target of another Fortran pointer? That seems like nonsense. That it cannot be part of a pending I/O transfer? That seems like nonsense. That it cannot be a local variable of a procedure? That seems like nonsense. That it cannot be a component of an object of derived type? That seems like nonsense. What other "in use by any other Fortran entity" is there? 3. Edits for undefinition ========================= Rather than make the program nonconformant, which existing wording in 15.2.3.3p3 does... [445:16 15.2.3.3p3 third paragraph of description of FPTR] After "entity" insert "X". [445:22-24 15.2.3.3p3 third paragraph of description of FPTR] Replace The final two sentences of the paragraph, viz. "In this case... target". with a new paragraph: "If X is not a Fortran pointer, not an unsaved Fortran local variable of a procedure instance that has completed execution, not a variable in an unsaved common block that is accessible only in instances of procedures that have completed execution, and not a C object for which the storage duration as described in subclause 6.2.4 of ISO/IEC 9899 has become indeterminate, FPTR becomes associated with X. If X is a Fortran pointer that is either disassociated, or was associated when its association status was inquired by C_LOC and its target has not become deallocated, the association status of FPTR becomes the same as X. If X is allocatable and has not become deallocated, FPTR becomes associated with X. Otherwise, the pointer association status of FPTR becomes undefined." [446:4+] Insert a Note: "NOTE 15.2a Even if the association status of FPTR is defined, the value of the target of FPTR might be undefined." 4. Edits for nonsense ===================== [445:27-446:1 15.2.3.3p3 fourth paragraph of description of FPTR] If "shall not be in use by any other Fortran entity" is nonsense, delete "shall not be in use by any other Fortran entity, and". If it's not nonsense, can somebody please provide edits to explain it?