J3/10-168 To: J3 From: Malcolm Cohen Subject: Interp on impure elemental functions. Date: 2010 June 01 ---------------------------------------------------------------------- NUMBER: TITLE: Impure elemental restrictions KEYWORDS: IMPURE, ELEMENTAL DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: With the following two impure elemental procedures, which perform essentially the same calculations, IMPURE ELEMENTAL SUBROUTINE one(x,y) INTENT(IN) x INTENT(OUT) y REAL :: z = 0 y = x + z z = x END SUBROUTINE IMPURE ELEMENTAL REAL FUNCTION two(x,y) INTENT(IN) x INTENT(OUT) y REAL :: z = 0 y = x + z z = x two = y - z END FUNCTION consider these references: REAL a(10),b,c ... CALL one(b,a) ! (i) ok, equivalent to CALL one([(b,i=1,10)],a) CALL one(a,b) ! (ii) not ok, prohibited by 12.8.3p1, sentence 2. c = two(b,a) ! (iii) ok, like (i) d = two(a,b) ! (iv) NOT prohibited!?! Was allowing case (iv) an oversight? ANSWER: Yes, this was an oversight: after adding impure elementals, the elemental subroutine argument restrictions need to apply to elemental functions as well. EDITS to 10-007: [314:7+] Insert new paragraph as follows. "In a reference to an elemental procedure, actual arguments that correspond to INTENT (OUT) or INTENT (INOUT) dummy arguments shall either be all be scalar or all be arrays. All actual arguments shall be conformable." [314:11-12] In 12.8.2, delete the third sentence; that sentence reads "For those ... conformable.". {Redundant with new paragraph.} [314:16-19] In 12.8.3, delete the second sentence; that sentence reads "In a reference ... conformable with them.". {Redundant with new paragraph.} NOTE: These edits subsume the one in the interp "Elemental subroutine restrictions". SUBMITTED BY: Malcolm Cohen HISTORY: 10-168 m192 Submitted ----------------------------------------------------------------------