To: J3 J3/13-226r1 From: Malcolm Cohen/Dick Hendrickson Subject: Interp from c.l.f Date: 2013 February 12 ---------------------------------------------------------------------- NUMBER: F08/0088 TITLE: Can ALLOCATE with SOURCE= have side-effects in a PURE proc? KEYWORDS: Allocate, SOURCE=, PURE, side-effects DEFECT TYPE: Erratum STATUS: Under J3 consideration QUESTION: On comp.lang.fortran Ian Harvey brought up a pointer/PURE question. Given a type definition like type :: int_ptr integer, pointer :: i end type int_ptr And a PURE function like PURE function FUN (arg) type(int_ptr), intent(in) :: arg type(int_ptr), allocatable :: tmp FUN = 1 allocate (tmp, source=arg) tmp%i = 2 end function fun Is FUN standard conforming? Doesn't the use of source=arg allow the function to modify a global entity via the tmp%i = ...? There don't seem to be any constraints on what arg%i can point to, which means that the assignment to tmp%i can have side effects. Note that C1283(1) prevents usage like arg%i = 2 ANSWER: This was not intended to be standard-conforming. An edit is supplied to remedy this oversight. EDITS: [312:37] Delete "or" and add a new item "(4a) as the in a SOURCE= clause if the designator is of a derived type that has an ultimate pointer component, or" SUBMITTED BY: Dick Hendrickson HISTORY: 13-226 m200 F08/0088 submitted 13-226r1 m200 Edits added. ----------------------------------------------------------------------