(j3.2006) allocatable components and TRANSFER

Robert Corbett Robert.Corbett
Fri Oct 30 05:32:01 EDT 2009


Malcolm Cohen wrote:
> Robert Corbett wrote:
> 
>> A member of Sun's Fortran team raised a question about
>> allocatable components and the intrinsic function
>> TRANSFER.  He (in effect) asked if the program
> 
> 
> I have never thought that TRANSFER to or from an object with an 
> allocatable component ought to be allowed.  In general, doing that is 
> going to leak memory or corrupt memory (unless we mandate garbage 
> collection, though maybe some slightly less onerous implementation 
> techniques would suffice).  There doesn't seem to be any functionality 
> gain in allowing it.

At least the program presented as an example in my e-mail works
without leaking or corrupting memory using the three compilers I
tried.  All of them allocate a new array for Y%A as part of the
assignment to Y.  They all deallocate both X%A and Y%A at the
end of the program.  I can imagine implementations that do not,
but they are not obvious implementations.

Bob Corbett



More information about the J3 mailing list