(j3.2006) Interpretation request SOURCE= in PURE procedures

Richard hendrickson dick.hendrickson
Tue Jan 1 14:39:40 EST 2013



Here's  an attempt at an interpretation request.  Unfortunately, I've forgotten  
how to make 

the document submitter work.  I hope someone can do enough  reformatting to put 
it in 

the paper queue.

Dick Hendrickson

------------------------------


                                                     J3/13-yy NUMBER: F08/ZZZZ 
TITLE: Can an allocate with SOURCE= have side-effects 

in a Pure procedure? 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.

C1283(1) prevents usage like

    arg%i = 2

ANSWER 
Of course it isn't standard conforming!  
Words modeled after C1283(4) will be added.  EDITS 

Add to C1283:  "..."

SUBMITTED BY: Dick Hendrickson  HISTORY: 13-WWW    m200  F08/ZZZZ submitted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20130101/6fdde0e0/attachment.html 



More information about the J3 mailing list