public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58859] New: throwing exceptions in destructors causes std::terminate called too early.
@ 2013-10-24  5:47 meng at g dot clemson.edu
  2013-10-24  5:50 ` [Bug c++/58859] throwing exceptions in destructors causes std::terminate called unnecessarily meng at g dot clemson.edu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: meng at g dot clemson.edu @ 2013-10-24  5:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58859

            Bug ID: 58859
           Summary: throwing exceptions in destructors causes
                    std::terminate called too early.
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: meng at g dot clemson.edu

the following program does not execute (2) for g++-4.8.[01] -std=c++11 and I
think this is a bug. I tested the program on g++-4.[67].[01] with or without
c++11 enabled, and g++-4.8.0 with c++11 flag, and in VS 2010, in all these
cases, (2) was executed and the program finished without a call to
std::terminate. My understanding is that the throw expression happens before
stack unwinding and that there is a matching handler, therefore, std::terminate
should not be called.

----------------------- BEGIN -----------------------
#include <iostream>

struct test_t
{
 test_t () { std::cout << " test_t @ " << this << std::endl; }
~test_t () { std::cout << "~test_t @ " << this << std::endl; throw 0; }
};

int main ()
{
 try
 {
  test_t const t; // (1)
 }
 catch (...)
 {
  std::cout << __LINE__ << std::endl; // (2)
 }
}
-----------------------  END  -----------------------


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-24  9:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-24  5:47 [Bug c++/58859] New: throwing exceptions in destructors causes std::terminate called too early meng at g dot clemson.edu
2013-10-24  5:50 ` [Bug c++/58859] throwing exceptions in destructors causes std::terminate called unnecessarily meng at g dot clemson.edu
2013-10-24  6:05 ` glisse at gcc dot gnu.org
2013-10-24  6:34 ` meng at g dot clemson.edu
2013-10-24  6:42 ` meng at g dot clemson.edu
2013-10-24  9:16 ` paolo.carlini at oracle dot com

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).