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. For instance, borrowing Lars'
code,
PROGRAM TEST
IMPLICIT NONE
REAL, DIMENSION(:), POINTER :: a, b
ALLOCATE (a(1:0))
b => a
if (ASSOCIATED(b)) DEALLOCATE(b)
END PROGRAM TEST
According to the standard the deallocation will not be executed. I
can't find anything in the standard that says that a 0 sized array
should not use any memory. So this could result in a memory leak. Or
am I missing something?
In the above program, what is the standard conforming result for
ASSOCIATED(a)? Is that also FALSE? Or is there a difference between
the status of a and b?
thanks,
-robert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|