[Bug fortran/46174] [OOP] ALLOCATE with SOURCE: Deep copy missing
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 26 07:44:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46174
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-26 07:44:15 UTC ---
(In reply to comment #1)
> What about MOLD= for polymorphic variables?
MOLD= should work. Allocate with mold= allocates memory for the effective type
of mold and initializes with the default initializer. By default, allocatable
components are not allocated and thus there is no problem. (SOURCE= also works
if (currently: and only if) all allocatable components are not allocated.)
* * *
Similarly affected: Deallocation when leaving the scope: The allocatable
components of the effective type are not deallocated. Example:
implicit none
type t
end type t
type, extends(t) :: t2
integer, allocatable :: all
end type t2
class(t), allocatable :: a
if (allocated(a)) call foo()
end
If one looks at the dump, one sees that only allocatable components of the
declared type ("t", here: none) but not allocatable components of the effective
type are freed. I think that's tightly coupled to FINALization subroutines,
i.e. PR 37336.
More information about the Gcc-bugs
mailing list