From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23448 invoked by alias); 13 Nov 2002 19:16:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 23422 invoked by uid 71); 13 Nov 2002 19:16:01 -0000 Resent-Date: 13 Nov 2002 19:16:01 -0000 Resent-Message-ID: <20021113191601.23421.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, sunil.k.davasam@intel.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, sunil.k.davasam@intel.com Received: (qmail 23118 invoked by uid 61); 13 Nov 2002 19:15:25 -0000 Message-Id: <20021113191525.23117.qmail@sources.redhat.com> Date: Tue, 19 Nov 2002 19:06:00 -0000 From: sunil.k.davasam@intel.com Reply-To: sunil.k.davasam@intel.com To: gcc-gnats@gcc.gnu.org Cc: sunil.k.davasam@intel.com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: sunil.k.davasam@intel.com Subject: c++/8563: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling. X-SW-Source: 2002-11/txt/msg00623.txt.bz2 List-Id: >Number: 8563 >Category: c++ >Synopsis: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Nov 13 11:16:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: sunil.k.davasam@intel.com >Release: gcc-3.2 >Organization: >Environment: I tried on IA32 Redhat8.0 product, with gcc3.2 compiler. >Description: This testcase has a exception in derived class destructor, there is no catch inside destructor. There is a matching catch in main(). This is to check whether the base class destructor is called during exception handling. -------------------------t2.cpp........................ #include struct C1 { virtual int f9() { return 1; } C1() { printf("C1()\n" ); } ~C1() { printf("~C1()\n" ); } }; struct C2 : public C1 { C2() { printf("C2()\n" ); } ~C2() { printf("~C2()\n" ); throw 1; } }; int main() { try { C2 o2; } catch ( C1 o1 ) { printf("Catching C%d exception.\n",1 ); } catch ( int i ) { printf("Catching int exception.\n" ); } return 0; } ---------------------------------------------- Expected output: ------------ C1() C2() ~C2() ~C1() Catching int exception. ------------- Actual output: -------- C1() C2() ~C2() Catching int exception. -------- Based on C++ Standard ( except.ctor ) 15.2.2: An object that is partially constructed or partially destroyed will have destructors executed for all of its fully constructed subobjects, that is, for subobjects for which the constructor has completed execution and the destructor has not yet begun execution. ------- >How-To-Repeat: [skdavasa@csattert1 failed_testcases]$ g++ t2.cpp [skdavasa@csattert1 failed_testcases]$ a.out C1() C2() ~C2() Catching int exception. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="t3.cpp" Content-Disposition: inline; filename="t3.cpp" #include struct C1 { virtual int f9() { return 1; } C1() { printf("C1()\n" ); } ~C1() { printf("~C1()\n" ); } }; struct C2 : public C1 { C2() { printf("C2()\n" ); } ~C2() { printf("~C2()\n" ); throw 1; } }; int main() { try { C2 o2; } catch ( C1 o1 ) { printf("Catching C%d exception.\n",1 ); } catch ( int i ) { printf("Catching int exception.\n" ); } return 0; }