public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: mf@cfdrc.com To: gcc-gnats@gcc.gnu.org Subject: c++/4250: destructor is not called during stack unwinding after exception Date: Thu, 06 Sep 2001 09:46:00 -0000 [thread overview] Message-ID: <20010906163902.8125.qmail@sourceware.cygnus.com> (raw) >Number: 4250 >Category: c++ >Synopsis: destructor is not called during stack unwinding after exception >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Sep 06 09:46:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Michal Furmanczyk >Release: gcc 3.0 (build with --enable-threads) >Organization: >Environment: i686-pc-linux-gnu >Description: When there is a try-catch block in function, local variables located before this block and the exception is thrown in this block but not catch the destructors of local variables are not called. Exception is catch in another try-catch block outside the function, therefore after the point when local variables should be destroy. >How-To-Repeat: Compile this code with: g++ -o test test.cpp The result program print only: ctor called it should print: ctor called, dtor called The same is with -O1 and -O2 option. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="test.cpp" Content-Disposition: inline; filename="test.cpp" #include <iostream> #include <stdexcept> class Test { public: Test() { std::cerr << "ctor called" << std::endl; } ~Test() { std::cerr << "dtor called" << std::endl; } }; void e() { throw std::logic_error("test"); } void f() { Test t; try { e(); } catch(std::runtime_error&) { } } int main() { try { f(); } catch(std::exception&) { } return 0; }
next reply other threads:[~2001-09-06 9:46 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-09-06 9:46 mf [this message] 2001-09-07 22:11 rodrigc 2001-09-10 10:46 Michal Furmanczyk 2001-09-10 12:35 rodrigc
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=20010906163902.8125.qmail@sourceware.cygnus.com \ --to=mf@cfdrc.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).