From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7683 invoked by alias); 22 Jan 2012 02:16:20 -0000 Received: (qmail 7673 invoked by uid 22791); 22 Jan 2012 02:16:19 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TW 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; Sun, 22 Jan 2012 02:16:06 +0000 From: "garynot at comcast dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/51940] New: Ada.Finalization of passed function return value skipped if exception raised in routine Date: Sun, 22 Jan 2012 10:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ada X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: garynot at comcast dot net 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: 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-01/txt/msg02498.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51940 Bug #: 51940 Summary: Ada.Finalization of passed function return value skipped if exception raised in routine Classification: Unclassified Product: gcc Version: 4.5.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassigned@gcc.gnu.org ReportedBy: garynot@comcast.net Created attachment 26409 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26409 Sample failing program. Very simple code. When a finalizable value is returned as a function result and passed to a routine, if that routine terminates with an exception then the Finalization routine is not called on the function result. The value thus escapes from finalization control when it should not. gcc -c -gnata -gnatE -fstack-check -gnatef -gnatf -gnatm50 -gnatn -gnato -gnatwe -gnatwi -gnatwj -gnatwK -gnatwl -Wuninitialized -gnatVa -pass-exit-codes -O -g -I- -gnatA /home/geb/foo.gnat.bug4/pb_code_main.adb gnatbind -E -m50 -Sin -static -we -I- -x /home/geb/foo.gnat.bug4/pb_code_main.ali gnatlink /home/geb/foo.gnat.bug4/pb_code_main.ali -g -v -o /home/geb/foo.gnat.bug4/pb_code_main ./pb_code_main Initialize 3216937700 0 Value'Address 3216937700 0 ---0---- 0 Adjust 3216937680 0 A'Address 3216937680 1 Finalize 3216937680 1 ---1---- 0 Adjust 3216936828 0 X'Address 3216936828 1 Adjust 134716096 1 Finalize 3216936828 2 Adjust 3216937668 1 Finalize 134716096 2 B'Address 3216937668 1 Finalize 3216937668 1 ---2---- 0 Adjust 3216936828 0 X'Address 3216936828 1 Adjust 134716096 1 Finalize 3216936828 2 Y'Address 134716096 1 **Notice lack of Finalization call on Y** ---3---- => 1 Adjust 3216936828 1 X'Address 3216936828 2 Adjust 134716096 2 Finalize 3216936828 3 Y'Address 134716096 2 **Notice lack of Finalization call on Y** **Notice That both Y's have same address, so Y was deallocated or reused without Finalization** ---4---- => 2 ---5---- 2 Finalize 3216937700 2