(j3.2006) does move_alloc violate restrictions in 12.5.2.13?

Jim Xia jimxia
Wed Oct 28 14:30:34 EDT 2009


> The rules in 12.5.2.13 (and elsewhere in the standard) are for 
> procedures written in Fortran. Most of the intrinsics, and especially 
> ones like MOVE_ALLOC, are most likely not written in Fortran. 


Nice shelter by "not written in Fortran".  So assume foo is written in C, 
then "call foo(a, a)" is perfectly legal by this definition even though 
you know foo assigns 1 to its first argument, 2 to the 2nd? -- sigh


> MOVE_ALLOC is probably either inline code, or a C library routine, that 
> plays games with the internals of the respective dope vectors for the 
> arguments. It was created because you can't do these sorts of things in 
> Fortran. 


Dope vectors are structures, not magic.  When dealing with copying data 
from one structure to another, there are bounds to be side-effects, 
particularly these structures are supposed to do book-keeping the data 
addresses.



> 
> The specific rule in 12.5.2.13, number (2), only talks about references 
> to the associated actual argument through the dummy argument or its 
> values being affected.  Even if there were dummy arguments in the 
> Fortran sense, these restrictions would not seem to apply to MOVE_ALLOC. 

>   The allocatable arguments themselves are not referenced or defined - 
> the operations are on the dope vectors.


I doubt it's irrelevant.  Normally you don't have this sort of problem 
with allocatables, since by default they're making copies.  Only pointers 
need to be guarded against these side-effects.  That's why pointers are 
explicitly spelled out in this section.  This MOVE_ALLOC is very much like 
pointer in this aspect.  If you're familiar with C++'s auto_ptr, I'd say 
MOVE_ALLOC is nearly identical, in functionality, to assigning one 
auto_ptr to another.  The side-effect is obvious here.  It looks like we 
may have to explicitly add MOVE_ALLOC to 12.5.2.13 as an exception.


Cheers,


Jim Xia

XL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444  Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM

http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://j3-fortran.org/pipermail/j3/attachments/20091028/7e5d49e8/attachment.htm>



More information about the J3 mailing list