J3/09-281
To: J3
From: Van Snyder and Malcolm Cohen
Subject: External as .
Date: 2009 August 13
References: 04-007
NUMBER: F03/0138
TITLE: External as
KEYWORDS: procedure name, procedure pointer, procedure pointer
assignmant
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
7.4.2 C727 says a " [that is a ] shall
be the name of an external ... procedure...."
To be passed as an actual argument, a procedure needs to have the
EXTERNAL attribute, but there appears to be no such requirement for
being a target in a procedure pointer assignment.
(1) Is the following example standard-conforming?
PROGRAM example1
PROCEDURE(),POINTER :: p
PROCEDURE(REAL),POINTER :: q
p => x
CALL x
q => y
PRINT *,y(5)
CALL p
PRINT *,q(5)
END
SUBROUTINE x
PRINT *,'ok so far'
END
FUNCTION y(n)
y = SQRT(REAL(n))
END
(2) If example1 is standard-conforming, is this example conforming?
MODULE exmod
PROCEDURE(),POINTER :: p
CONTAINS
SUBROUTINE test
CALL p
END SUBROUTINE
END
PROGRAM example2
USE exmod
p => x
CALL test
END
SUBROUTINE x
PRINT *,'ok'
END
ANSWER:
(1) Yes, this example is conforming. As correctly noted, there is no
requirement for the EXTERNAL attribute in a procedure pointer
assignment, and both X and Y are known within the main program
to be external procedures.
(2) This example was not intended to be conforming. An edit is
provided to clarify this.
EDIT:
[144:5-6] In 7.4.2 Pointer assignment, constraint C727,
Change "an external, module," to "a module",
Change "or a procedure pointer" to
"a procedure pointer, or an external procedure that is accessed by
USE or host association, referenced in the scoping unit as a
procedure, or that has the EXTERNAL attribute".
SUBMITTED BY: Van Snyder
HISTORY: 09-281 m189 Submitted