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]

[Q] destructors vs terminate


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 ();
}


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