From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9815 invoked by alias); 4 Nov 2012 18:32:46 -0000 Received: (qmail 9734 invoked by uid 48); 4 Nov 2012 18:32:29 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55207] Automatic deallocation of variables declared in the main program Date: Sun, 04 Nov 2012 18:32: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: janus 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: 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" 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/msg00297.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55207 --- Comment #1 from janus at gcc dot gnu.org 2012-11-04 18:32:29 UTC --- Patch: Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 193135) +++ gcc/fortran/trans-decl.c (working copy) @@ -3771,9 +3771,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gf else gfc_restore_backend_locus (&loc); - /* Deallocate when leaving the scope. Nullifying is not - needed. */ - if (!sym->attr.result && !sym->attr.dummy) + /* Automatic deallocation when leaving the scope. + Nullifying is not needed. */ + if (!proc_sym->attr.is_main_program + && !sym->attr.result && !sym->attr.dummy) { if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.codimension) This regresses on: FAIL: gfortran.dg/allocatable_scalar_9.f90 -O0 scan-tree-dump-times original "__builtin_free" 32 FAIL: gfortran.dg/coarray_lib_alloc_2.f90 -O scan-tree-dump-times original "_gfortran_caf_deregister .&yy._data.token, 0B, 0B, 0.;" 1 FAIL: gfortran.dg/move_alloc_4.f90 -O0 scan-tree-dump-times original "__builtin_free" 9