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

Robert Corbett Robert.Corbett
Fri Oct 30 01:42:08 EDT 2009


Van Snyder wrote:

> Is this subroutine standard conforming?
> 
> subroutine Move_Alloc ( A, B )
>  real, intent(inout), allocatable :: A
>  real, intent(out), allocatable :: B
>  allocate ( b )
>  b = a
>  deallocate ( a )
> end subroutine Move_Alloc
> 
> Now, how about if I call it
>  call move_alloc ( x, x )
> 
> The call is a problem, not the subroutine.
> 
> There's no problem with the standard's description of the intrinsic 
> subroutine Move_Alloc.

I am beginning to think there is a problem with the standard's
description of MOVE_ALLOC.  I no longer think that the rules
given in Section 12.5.2.13 are sufficient to make the call

       CALL MOVE_ALLOC(X, X)

nonstandard.  The problem is that MOVE_ALLOC does not reference
either of its arguments. If MOVE_ALLOC did reference either of
its arguemnts, that would be a problem, because paragraph 2 on
page 117 states

       A reference is permitted only if the variable is
       defined.

The standard clearly intends to allow MOVE_ALLOC to be called
even when both the TO and the FROM arguments are undefined.
Because MOVE_ALLOC does not reference either of its arguments,
the prohibitions in Section 12.5.2.13 do not apply.

In the absence of a restriction banning calls where TO and FROM
are associated with the same object, a call of MOVE_ALLOC where
the FROM argument is allocated is a problem.  In such a case,
the standard requires the TO argument to become allocated and
the FROM argument to become unallocated.

I think there needs to be an explicit restriction against the
TO and FROM arguments referencing the same data entity.

Bob Corbett

> Jim Xia wrote:
> 
>>
>>  
>> > While I agree that intrinsics can be special, I would expect the
>> > standard to call out the cases where they are.  As I explained in my
>> > previous response (copied below), I think MOVE_ALLOC is
>> > subject to the usual rules.
>>
>>
>> Thanks Bob for your reply.  That is not what I have in mind 
>> unfortunately.  I'm a bit of tired on the discussions on this very 
>> topic, and have many other issues to work with.  But I'll not be 
>> surprised to see the same question re-surface in a few years time when 
>> more implementations available.  Someone might ask the same question 
>> if the following code is standard conforming
>>
>> subroutine foo (a, b)
>>    ...
>>    call move_alloc(a,b)
>> end subroutine
>>
>>
>> As of right now, I doubt it is.  But let's put it aside as I don't 
>> feel the email correspondence is really productive.
>>
>> 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
>>
> 
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list