From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9191 invoked by alias); 26 Oct 2010 19:00:50 -0000 Received: (qmail 9168 invoked by uid 22791); 26 Oct 2010 19:00:45 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 19:00:40 +0000 From: "domob at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46174] [OOP] ALLOCATE with SOURCE: Deep copy missing X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: domob at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 26 Oct 2010 19:00:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02233.txt.bz2 Message-ID: <20101026190000.Zj0zAhnQ-mbVTJuVCtLe4TLiFcwmDKeNymMX6qTJGuc@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46174 --- Comment #4 from Daniel Kraft 2010-10-26 19:00:34 UTC --- (In reply to comment #3) > Possible implementation scheme: vtab$t contains besides the normal type-bound > procedures and init/size/hash also an two function points: $copy and $free, > which are of the kind: > > void $free (struct *DT) { > ... free derived types > if (DT->$vtab->$extends && DT->$vtab->$extends->$free) > DT->$vtab->$extends->$free (DT) > } > > That is, each effective type cleans up its own allocatable components and moves > on to the parent. If the parent does not have an allocatable component itself, > the $free pointer directly points to an ancestor which has -- or is NULL if no > such ancestor exists. The $copy version works alike. Note that this is basically what I would suggest to do also for finalization -- in principle, "all" that needs to be extended from your scheme is that $free also has to call the appropriate finalizer in-between the frees. (This recursing on parent type is also exactly as finalization is specified by the standard.) And because there may be multiple FINAL procedures differing in rank and the "correct one" must be called in any case, I fear that we have to create a $free for each rank, too (or play some nasty tricks). But that should be more a mechanical change and bloat the resulting code instead of being hard to implement.