J3/04-401 Date: 1 October 2004 To: J3 From: Van Snyder Subject: Interpretation request on procedure pointers (F03/0012 revisited) Reference: J3/04-358r2 NUMBER: F03/0012 TITLE: Procedure pointers and the EXTERNAL attribute KEYWORDS: Procedure pointers, EXTERNAL DEFECT TYPE: Error STATUS: QUESTION: Is the following program unit standard conforming? SUBROUTINE SUB ( RPP ) REAL, EXTERNAL, POINTER :: RPP EXTERNAL :: PP POINTER :: PP PROCEDURE(REAL), POINTER :: PPP => NULL() END SUBROUTINE SUB The last sentence of "5.1.2.6 EXTERNAL attribute" appears to indicate that it is allowed: "A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer." That the title of subclause 12.2.1.2 is "Characteristics of dummy procedures and dummy procedure pointers" suggests that it is allowed. That subclause continues "... whether it is a pointer, ..." so it was clearly envisioned that at least dummy procedures could have the POINTER attribute. C1216 [264:30] appears to require PPP to be allowed: "C1216 (R1214) If => appears in , the procedure entity shall have the pointer attribute." On the other hand, A conspiracy of C512 [72:28-29] "C512 (R501) If the POINTER attribute is specified, the ALLOCATABLE, TARGET, EXTERNAL, or INTRINSIC attribute shall not be specified." the second sentence of subclause 5.1.2.6 [80:38-40] "This [EXTERNAL] attribute may also be specified by ... a ..." the first paragraph of subclause 5.2 [85:15ff] "The combination of attributes that may be specified for a particular entity is subject to the same restrictions ... regardless of the method of specification. This also applies to the PROCEDURE, EXTERNAL and INTRINSIC statements." and the last sentence of the first paragraph of 12.3.2.3 [264:8] "It [the procedure declaration statement] specifies the EXTERNAL attribute...." appears to completely wipe out procedure pointers (PPP because of the first paragraph of 12.3.2.3). C521 [73:6-7] and C568 [91:5] also appear to prohibit RPP and PP: "C521 (R504) The shall be the name of an external function, a function dummy procedure{, or a statement function}." "C568 (R541) A shall also be declared in a ." But then the first paragraph after R1210 (defining the EXTERNAL statement) [264:1] appears to allow RPP and PP: "Each shall be the name of ... a procedure pointer...." ANSWER 1: The discussion of procedure pointers is indeed inconsistent. The program unit is intended to be standard conforming. It was an oversight during the development of the procedure pointer facility that the EXTERNAL attribute was not removed from C512, that "procedure pointer" was not added to C521, and that an external statement and specifying the EXTERNAL attribute in a type declaration statement were not allowed in C568. It is not helpful that the last sentence of the first paragraph of subclause 5.2 refers to "PROCEDURE ... statements" (which could be confused with the PROCEDURE statement in an interface block) where it should refer to "procedure declaration ... statements." EDIT 1: Delete ", EXTERNAL" from C512. Insert ", a procedure pointer" after "dummy procedure" in C521. Replace the last sentence of the first paragraph of subclause 5.2 by "This also applies to procedure declaration statements, and to EXTERNAL and INTRINSIC statements." EDIT 1a: Insert ", an , or a with the EXTERNAL attribute" at the end of C568. EDIT 1b: Replace C568: "C568 (R541) The EXTERNAL attribute (5.1.2.6) shall be explicitly specified for a ." but whether this allows pointer :: BOHICA interface subroutine BOHICA end subroutine BOHICA end interface may be fodder for yet another interp. ANSWER 2: The discussion of procedure pointers is indeed inconsistent. The declaration of PPP is intended to be standard conforming, but the declarations of RPP and PP are not. It was an oversight during the development of the procedure pointer facility that the EXTERNAL attribute was not removed from C512. It was not intended that a procedure pointer can be declared by using an EXTERNAL statement or the EXTERNAL attribute in a type declaration statement, so the declarations of RPP and PP are prohibited (see C521 and C568). It is not helpful that the last sentence of the first paragraph of subclause 5.2 refers to "PROCEDURE ... statements" (which could be confused with the PROCEDURE statement in an interface block) where it should refer to "procedure declaration ... statements." EDIT 2: Delete ", EXTERNAL" from C512. Replace the last sentence of the first paragraph of subclause 5.2 by "This also applies to procedure declaration statements, and to EXTERNAL and INTRINSIC statements." Remove ", a procedure pointer" from the first line of the first paragraph after R1210. SUBMITTED BY: Van Snyder HISTORY: 04-358 m169 submitted 04-358r2 m169 revised 04-401 m170 revised