From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7221 invoked by alias); 27 Nov 2012 20:04:40 -0000 Received: (qmail 7149 invoked by uid 48); 27 Nov 2012 20:04:25 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/37336] Fortran 2003: Finish derived-type finalization Date: Tue, 27 Nov 2012 20:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 2012-11/txt/msg02578.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D37336 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #14 from Tobias Burnus 2012-11-27 2= 0:04:21 UTC --- (In reply to comment #13) > class(child),allocatable :: infant > allocate(infant,source=3Dnew_child()) > ... the finalizer is called twice: Once at the end of the main program, a= nd > once through the _copy procedure (which is invoked by the ALLOCATE statem= ent), > I think. Not sure if this is the expected behavior. The invocation through the _copy wrapper is a bug for ALLOCATE. However, it= 's fine for "a =3D b" which invoke _copy. I believe _copy should use "intent(i= nout) dst" instead of "intent(out)" dest =E2=80=93 and if needed (e.g. intrinsic = assignment), _final should be called directly. Then one can also replace "calloc" and "memset '\0'" by a simple "malloc". (Caveat: One should check that coarray components are properly handled; possibly, _copy also needs a "coarray" argument as _final has.) * * * Current FINAL-wrapper patch (submitted) - it is still preparatory and doesn= 't call finalization subroutines: http://gcc.gnu.org/ml/fortran/2012-11/msg00086.html See also draft patches at https://userpage.physik.fu-berlin.de/~tburnus/fin= al/ and http://gcc.gnu.org/ml/fortran/2012-11/msg00009.html