--On 23 September 2004 8:47 -0400 Aleksandar Donev
<[log in to unmask]> wrote:
> J.L.Schonfelder wrote:
>
>> I would have said deallocate should
>> only be used if the pointer was previously associated with space by
>> allocation.
>
> I disagree with this. Transfering allocated space between objects is a
> useful thing and should be supported in some way in the language. Note
> that in F2003 we added the possibility of doing so between ALLOCATABLEs
> via the MOVE_ALLOC intrinsic. It is the equivalent of
> P=>Q
> Aleks
I have no objection to
P=>Q
but I have a problem with
ALLOCATE(Q(N:M))
....
P=>Q
....
DEALLOCATE(P)
This is likely cause a problem since as far as I can see this leaves Q
dangling. However, I am pretty sure that such code is not defined to be
nonstandard.
However, if the pointer assignment was
P=>Q(N:M)
even though I can't quote text from the standard, I believe deallocating a
pointer that is associated with a slice is not strictly standard conforming
and this is one of the reasons for there being a difference between a whole
array and a slice even if the slice comprises all the elements.
I do not believe the standard is written in a way that would require the
processor to diagnose either case but I think the user is not allowed to
deallocate a pointer to a slice; if he does the processor may start WW3 if
it likes.
--
Dr. Lawrie Schonfelder
Honorary Senior Fellow, University of Liverpool
Home: 1 Marine Park, West Kirby, Wirral, UK, CH48 5HN
Phone: +44 (151) 625 6986
|