[Q] destructors vs terminate

Richard Henderson rth@redhat.com
Fri Aug 3 16:51:00 GMT 2001


Should the following test case pass?  If so, there's some
holes that'll want patching in libsupc++...


r~


#include <exception>
#include <cstdlib>

static void exit_ok () { std::exit (0); }
static void exit_err () { std::exit (1); }

struct A
{
  ~A()
  {
    std::set_terminate (exit_err);
    throw 1;
  }
};

int main ()
{
  std::set_terminate (exit_ok);

  try
    {
      A obj;
      throw 1;
    }
  catch (...)
    {
    }
  std::abort ();
}



More information about the Gcc mailing list