Print

Print


Norman Clerman (Opcon) wrote:

>     What happens if there is a hierarchy of types, a parent, say, a
> child, and a grandchild, and the child doesn't have an allocatable
> component, but the others do.
They should be automatically deallocated as well. Someone else will need
to dig out all the definitions from the standard to prove this: The
F2003 standard says "any allocated allocatable subobject is
deallocated", and so one needs to trace out quite a few terms before
figuring this out :-\

> A similar question extends to assignments: Does an intrinsic
> assignment do a "deep copy", as it is phrased in the report, for the
> following:
> y = x
> where both x and y are derived-type variables of type (outer) as
> defined in the example?
Yes, a deep copy should be done. Intrinsic assignment copies values, and
the way value is defined (at least in F2003) implies deep copying for
allocatables.

The only time when I am not sure whether we mandate that all memory be
deallocated for derived types is with the OOP stuff in F2x, in
particular when the dynamic type has allocatable components, but the
declared one does not? I imagine so, but could not tell you where the
standard says so.

Best,
Aleks