This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46174] [OOP] ALLOCATE with SOURCE: Deep copy missing
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 26 Oct 2010 07:44:18 +0000
- Subject: [Bug fortran/46174] [OOP] ALLOCATE with SOURCE: Deep copy missing
- Auto-submitted: auto-generated
- References: <bug-46174-4@http.gcc.gnu.org/bugzilla/>
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.