To: J3 J3/20-123 From: Robert Corbett Subject: Edits for procedure pointer association Date: 2020-February-27 Reference: 18-007r1 Introduction ------------ The Fortran standard currently specifies ways in which a procedure pointer can become associated with a dummy procedure. A procedure pointer should never be associated with a dummy procedure. An example of code that is not conformant under the current standard is PROGRAM MAIN EXTERNAL FPT POINTER FPT CALL SETFPT(SQRT) PRINT *, FPT(4.0) CONTAINS SUBROUTINE SETFPT(PROC) EXTERNAL PROC FPT => PROC END SUBROUTINE SETFPT END The pointer FPT should become associated with the intrinsic SQRT, but it currently becomes associated with PROC. When the program returns from SETFPT, FPT has undefined pointer association status. 1. Description ----------- The standard says that if the pointer target of a procedure pointer assignment is not a pointer, the pointer object becomes associated with the pointer target [10.2.2.4p1, 167:1]. That is correct if the pointer target is not a dummy argument. If the pointer target is a dummy argument, the pointer object should become associated with the ultimate argument associated with the dummy argument, not with the dummy argument itself. An edit is supplied to correct this oversight. Dummy procedures passed as actual arguments to dummy procedure pointers (15.5.2.9) create a similar problem. An edit is supplied to correct this oversight. 2. Edits ----- 10.2.2.4 "Procedure pointer assignment", paragraph 1, page 167:2 Replace "If the pointer target ... the pointer target." with "If the pointer target is not a pointer or a dummy argument, the pointer object becomes associated with the pointer target. If the pointer target is a nonpointer dummy argument, the pointer object becomes associated with the ultimate argument associated with the dummy argument." 15.5.2.9 "Actual arguments associated with dummy procedure entities", paragraph 5, page 309:21. Replace "INTENT(IN) ... with the actual argument." with "INTENT(IN); it becomes pointer associated with the actual argument if the actual argument is not a dummy argument, and otherwise with the ultimate argument associated with the actual argument." ------------------------