public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: sunil.k.davasam@intel.com To: gcc-gnats@gcc.gnu.org Cc: sunil.k.davasam@intel.com; Subject: c++/8453: ABI Issue: Destructors for already constructed objects not called when the exception is thrown inside constructor. Date: Mon, 04 Nov 2002 14:46:00 -0000 [thread overview] Message-ID: <20021104223739.16229.qmail@sources.redhat.com> (raw) >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 <stdio.h> 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:
next reply other threads:[~2002-11-04 22:46 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-11-04 14:46 sunil.k.davasam [this message] 2002-11-04 15:04 bangerth 2002-11-07 8:29 mmitchel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021104223739.16229.qmail@sources.redhat.com \ --to=sunil.k.davasam@intel.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).