J3/12-121 To: J3 From: Malcolm Cohen Subject: Interp vector subscript target Date: 2012 January 30 ---------------------------------------------------------------------- NUMBER: TITLE: Vector subscript target KEYWORDS: Pointer assignment, Vector subscript DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Consider PROGRAM m197006 REAL,TARGET :: x(100) = [ (i,i=1,100) ] REAL,POINTER :: p(:) TYPE t REAL,POINTER :: q(:) END TYPE TYPE(t) y p => x ! (1) y = t(x) ! (2) p => x( [ 1,4,9,25 ] ) ! (3) y = t(x( [ 1,4,9,25 ] )) ! (4) PRINT *,y%q END PROGRAM The pointer assignment statement at (1) associates P with X. The intrinsic assignment statement at (2) includes the effect of pointer assignment of X to Y%Q, but is not a pointer assignment statement. The pointer assignment statement at (3) is not standard-conforming according to 6.5.3.3.2 paragraph 2: "An array section with a vector subscript shall not be ... the in a pointer assignment statement" However, the intrinsic assignment statement at (4) is not subject to this requirement as it is not a pointer assignment statement. Note that the quoted paragraph is entirely duplicative, as in: - the first bullet item is covered by 12.5.2.4p18, - the second bullet item is covered by C724 in 7.2.2.2 (but C724 does not cover this case either), - the third bullet item is covered by C901 in 9.5.1. Some editorial improvements could be made. Q1. Was this intended to be allowed? Q2. If not, was it intended to be prohibited by a constraint like C724, or was it intended to be a simple requirement? (Editorial note: in any case surely the requirement should appear in the pointer assignment subclause.) ANSWER: A1. No, this was not intended. An edit is supplied to correct this. A2. Constraint C724 was intended to cover this case. An edit is supplied to correct his. EDIT: [124:6] 6.5.3.3.2 Vector subscript, paragraph 2, second bullet item, Change "the in a pointer assignment statement" to "the target in pointer assignment (C724)". [158:19-20] In 7.2.2.2 Syntax of the pointer assignment statement, C724, change ""(R737) A " to "A variable that is a pointer target", making the whole constraint read: "A variable that is a pointer target shall have either the TARGET or POINTER attribute, and shall not be an array section with a vector subscript." {Make the constraint apply to all forms of pointer assignment.} ALTERNATIVE A2: A2. Constraint C724 was not intended to cover this case, it was intended to be a simple requirement. An edit is supplied to clarify this. ALTERNATIVE EDITS: [124:6] 6.5.3.3.2 Vector subscript, paragraph 2, second bullet item, Change "the in a pointer assignment statement" to "the target in pointer assignment (7.2.2.3)". [159:26+] In 7.2.2.3 Data pointer assignment, before paragraph 7 which begins "If the pointer object has the CONTIGUOUS", insert new paragraph "The pointer target shall not be an array section with a vector subscript." {Add the prohibition as a simple requirement.} EDITORIAL (for next revision): Additional edits are suggested: [124:4] Change "An" to "Note that an", change "shall not be" to "is not permitted to be". [124:5] After "redefined" insert "(12.5.2.4)". [124:7] After "file" insert "(C901)". SUBMITTED BY: Malcolm Cohen HISTORY: 12-nnn m197 Submitted ----------------------------------------------------------------------