(j3.2006) Alleged contradiction

Robert Corbett Robert.Corbett
Sat Jan 16 05:46:47 EST 2010


Malcolm Cohen wrote:
> Robert Corbett wrote:
> 
>> Section 5.3.10, paragraph 2, page 97, states
>>
>>      The INTENT(IN) attribute for a pointer dummy argument
>>      specifies that during the invocation and execution of
>>      the procedure its association shall not be changed
>>
>>      except that it may become undefined if the target is
>>      deallocated other than through the pointer (16.5.2.5).
>>
>> The "except" portion of the quoted text makes it seem as if
>> the target of a pointer dummy argument is permitted to be
>> "deallocated other than through the pointer."
> 
> 
> Yes.
> 
>> Section 12.5.2.13, paragraph 1, page 300 states
>>
>>      While an entity is associated with a dummy argument,
>>      the following restrictions hold.
>>
>>      (1)  Action that affects the allocation status of
>>           the entity or a subobject thereof shall be
>>           taken through the dummy argument.
>>
>> That text seems to say that a target associated with a
>> pointer dummy argument can only be deallocated through the
>> pointer.
> 
> 
> No, on a sufficiently careful reading it does not seem to say that.
> 
> Allocation status is for allocatable variables.
> *Association* status is for pointers.
> 
> Therefore there is no contradiction.
> 
>> Therefore, the "except" clause quoted above
>> cannot apply to a standard-conforming program.
> 
> 
> Contrariwise.
> 
> Cheers,

My understanding of the intended meaning of the phrase "allocation
status" in item (1) of Section 12.5.2.13 differs from yours.  My
understanding of the phrase in that context is that it applies to
any allocated object.  The comments in Note 12.34 support my
interpretation.  There are no allocatable variables in the example
given in the note.  The variable A in the example is a pointer
variable, not an allocatable variable.  Under my interpretation,
the sentence

      Similarly,

      DEALLOCATE (A)

      would not be allowed because this affects the allocation
      of B without using B.

makes sense.  Under the interpretation that the phrase "allocation
status" in this context applies only to allocatable variables,
that sentence makes no sense.  Under that interpretation, there is
no prohibition against deallocating a pointer variable that is
argument associated with a variable dummy argument.  If the
standard included a provision that such a variable dummy argument
became undefined when the pointer was deallocated, I might believe
that the intent was to allow such deallocations, but there is no
such provision in Section 16.6.6.

As was discussed on this alias last month, the final sentence of
Note 12.34 is not supported by the text of the standard.  That
flaw does weaken arguments based on the other content of the note.
Nonetheless, I hope no one supposes that the standard intends to
allow a pointer variable to be deallocated while the pointer is
argument associated with a variable dummy argument.

Robert Corbett



More information about the J3 mailing list