To: J3 11-246 From: Van Snyder Subject: PDTR 29113 Lifetimes and Pointers Date: 2011 October 11 Reference: WG5/N1869 Discussion ---------- In PDTR 29113, paragraph 2 of subclause 5.3.7, one sees that if a dummy argument does not have the TARGET, ASYNCHRONOUS, or VOLATILE attributes, all C pointers to any part of the object its C descriptor describes become undefined on return from the call. The reason for ASYNCHRONOUS to be in the list is that Rolf Rabenseifner objected to the possibility of performance degradation caused by the TARGET attribute. If the criterion were based on the TARGET attribute alone, paragraphs 12.5.2.4p8-12 of 1539-1 would have covered all the cases. There appears to be no reason for VOLATILE to be in the list. In PDTR 29113, paragraph 3 of subclause 5.3.7, one sees the sentence "A Fortran pointer variable that is associated with the object described by a C descriptor shall not be accessed beyond the end of the lifetime of the C descriptor and the object it describes." There are at least three problems with this sentence. 1. It applies to all Fortran pointers that ever become associated with an object described by a C descriptor, no matter when or how. 2. The prohibition against accessing the Fortran pointer after the lifetime of the C descriptor is pointless, since the pointer is associated with the object the C descriptor describes, not with the C descriptor. Even if the C function has taken a copy to get a contiguous object, it's still the object described by the C descriptor that is under discussion, not a copy of it. If the caller has taken a copy to get a contiguous object, paragraphs 12.5.2.4p8-12 govern the pointer's association status. 3. In 1539-1, the word "accessed" is used with respect to coarrays, but more generally applies to accessibility by host or use association. It is not used in relation to pointers. Taken literally, it could be interpreted to mean that the pointer could not be the in a pointer assignment statement. The first and third of these are definitely mistakes in the construction of subclause 5.3.7. The second is covered by 12.5.2.4p8-12 and 16.5.2.4-5 of 1539-1. There is no discussion of the effect of the lifetime of an ordinary C object that is the target of a Fortran pointer. Edits ----- In the second paragraph of subclause 5.3.7, replace "TARGET, ASYNCHRONOUS, or VOLATILE" by "TARGET or ASYNCHRONOUS. In the third paragraph of subclause 5.3.7, remove the final sentence "A Fortran pointer ... it describes." After the fourth paragraph of subclause 5.3.7, insert a paragraph "If a Fortran pointer becomes associated with a C object, the association status of the Fortran pointer becomes undefined when the lifetime of the C object ends." Before subclause 6.10, add a subclause "6.9a Edits to clause 16" Within that subclause add the edit to 1539-1 "After 16.5.2.4p1(3) insert a list item '(3a) the target of the pointer is a C object and the lifetime of the C object ends,' "