From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20414 invoked by alias); 4 Nov 2002 22:46:03 -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 20358 invoked by uid 71); 4 Nov 2002 22:46:02 -0000 Resent-Date: 4 Nov 2002 22:46:02 -0000 Resent-Message-ID: <20021104224602.20357.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 16230 invoked by uid 61); 4 Nov 2002 22:37:39 -0000 Message-Id: <20021104223739.16229.qmail@sources.redhat.com> Date: Mon, 04 Nov 2002 14:46: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++/8453: ABI Issue: Destructors for already constructed objects not called when the exception is thrown inside constructor. X-SW-Source: 2002-11/txt/msg00182.txt.bz2 List-Id: >Number: 8453 >Category: c++ >Synopsis: ABI Issue: Destructors for already constructed objects not called when the exception is thrown inside constructor. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Nov 04 14:46:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: sunil.k.davasam@intel.com >Release: gcc - 3.2 >Organization: >Environment: Redhat 8.0 product ( ia32 ), United Linux 1.0 ( ia64 ) >Description: Based on C++ ABI, ( Section 3.3.3: Array Construction and Destruction API ) While creating an array of objects, If the constructor throws an exception, call the destructor for any already-constructed elements, and rethrow the exception. In the following example, The testcase wants to create an array of 4 objects. While creating 3rd object, it throws an exception. So, based on C++ ABI, destructors should be called for already constructed first 2 elements. When I compiled the testcase with gcc 3.2 compiler, I am getting different output. Contents of file : tt.cpp ------------------------- #include static int i = 0; struct C3 { C3() { if ( i == 2 ) throw 1; else i++; printf("%sC%d()\n", "", 3); } ~C3() { printf("%sC%d()\n", "~", 3); } }; C3 o3[4]; int main() { return 0; } [cmd_prompt]$ g++ tt.cpp [cmd_prompt]$ a.out C3() C3() Abort (core dumped) ----------- Expected output: C3() C3() ~C3() ~C3() Abort (core dumped) ----------- gcc compiler version: [cmd]$ g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i 386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 (Red Hat Linux Rawhide 3.2-1) Actually I tried on both IA32 and IA64 platforms. IA32 - Redhat Linux 8.0 product IA64 - United Linux 1.0 -------- >How-To-Repeat: [cmd_prompt]$ g++ tt.cpp [cmd_prompt]$ a.out C3() C3() Abort (core dumped) >Fix: >Release-Note: >Audit-Trail: >Unformatted: