Re: Allocatable arrays in derived types



On Apr 29, 5:58 am, paul.richard.tho...@xxxxxxxxx wrote:
The gfortran implementation of allocatable components attempts to
realise the extension to F95, TR15581:ftp://ftp.nag.co.uk/sc22wg5/N1351-N1400/N1379.pdf

Amongst other things, automatic memory deallocation/allocation on
assignment or with derived type constructors, automatic deallocation
on leaving scope and MOVE_ALLOC are implemented. In principle, memory
leakage should be prevented automatically. In practice, gfortran does
not quite manage this in the case of nested constructors but seems to
do OK otherwise. I am working on this and related issues and expect
to fix it soon.

Regards

Paul Thomas

gfortran is not alone in this regard. In the past, I have found and
reported leaks with allocatable components in several compilers --
specifically when evaluating expressions containing user-defined
operators and assignments that return derived types with allocatable
components. I believe Portland Group has fixed their leaks. Intel
promises to do so in the next release. IBM requires passing a
compiler flag to turn on automatic deallocations. I haven't
encountered the leaks in gfortran. g95 has seemed to be leak-free for
quite some time for allocatables and reports pointer allocations that
have not been deallocated upon program termination. I know nothing
about compiler design, but this must be a very difficult issue.
.