Print

Print



Richard Maine wrote:
> 
> [log in to unmask] writes:
>  > Michael Metcalf writes:
>  >  > Message text written by Lars Mossberg
>  >  > >After all, Fortran DOES support zero-sized objects and they DO exist and
>  >  > ARE defined and
>  >  > "a" and "b" DO point to the same target, or?<
>  >  >
>  >  > Agreed. But the standard says, in the definition of ASSOCIATED, that for
>  >  > zero-size arrays the result is false.
>  >  >
>  >
>  > This seems like an unfortunate choice.  I often test pointer
>  > association status before deallocation....
> 
> Different issue.  You are talking about the one-argument form of
> associated, which asks whether a pointer is associated with anything.
> That form works as you'd expect...Well, there are the issues of
> undefined association status, which may not be something you'd
> expect.  But there is nothing special about zero size for that
> form.
> 
> The special case for zero-sized arrays applies only to the
> two-argument form of associated, which asks whether two pointers
> are associated *WITH THE SAME THING* (or whether a pointer is
> associated with a particular target).
> 
> The standard says that two zero-sized pointers are never associated
> with the same thing (since they have no elements in common).  They
> may still both be associated - just not with the same thing.
> 
> I do happen to think that the standard's choice is, as you say,
> unfortunate.  But at least its a less common situation.

Yeah, it's an unfortunate choice.  Unfortunately, there are no
fortunate choices.  Suppose P1 and P2 are pointers, what should happen
to ASSOCIATED(P1,P2) for
    P1 => array(10:9)  ;  P2 => array(10:8)
or
    P1 => array(10:9)  ;  P2 => array(5:4)
or
    P1 => array(1:2:-1);  P2 => array(2:1)
or
    P1 => array(2:1)   ;  P2 => other_array(2:1)
or suppose "other_array" is actually a pointer and points to array.

The list of dumb things people can do with zero sized arrays is
unfortunately non-zero sized.

For what it's worth, I don't like the choice either.  In fact at
one X3J3 meeting I had a paper that "proved" TRUE was the best
result as the size of the arrays approached zero.

Dick Hendrickson


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%