This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Q] destructors vs terminate


On Aug  3, 2001, Richard Henderson <rth@redhat.com> wrote:

> Should the following test case pass?

It shall terminate with exit status 1.  As control passes from `throw
1' to `catch (...)'  in main, the destructor of `A obj' is invoked
[except.ctor]/1.  It calls std::set_terminate(), which modifies the
terminate_handler that will be run by std::terminate()
[lib.set.terminate], and only then does it throw 1, that triggers the
invocation of std::terminate() because the destruction of an object
during stack unwinding exits using an exception [except.terminate]/1
and [except.ctor]/3.  std::terminate() will call exit_err() because
that is the terminate_handler function in effect immediately after
evaluating the throw-expression `throw 1' in A::~A()
[lib.terminate]/1.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]