------- Comment #2 from jakub at gcc dot gnu dot org  2008-03-12 16:19 -------
Works just fine here, at least with:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>

void
stSigSegvHandler (int dummy)
{
  throw "SIGSEGV signaled";
}

int g_cnt;
struct StructWithDtor
{
  StructWithDtor () : m_cnt (g_cnt++) {}
  ~StructWithDtor () { printf ("~StructWithDtor: Count %d\n", m_cnt); }
  int m_cnt;
};

int
FuncNested1 (int *pi)
{
  StructWithDtor swd;
  return *pi;
}

int
FuncTop (int *pi)
{
  StructWithDtor swd;
  return FuncNested1 (pi);
}

int
main (int argc, const char *argv[])
{
  struct sigaction sa;
  sigemptyset (&sa.sa_mask);
  sa.sa_handler = stSigSegvHandler;
  sa.sa_flags = 0;
  sigaction (SIGSEGV, &sa, NULL);

  // Trigger SIGSEGV                                                            
  try
    {
      FuncTop (NULL);
    }
  catch (...)
    {
      puts ("Caught exception");
    }
}

(both i?86 and x86_64).  No idea why do you use a syscall directly, it makes
absolutely no sense.

~StructWithDtor: Count 1
~StructWithDtor: Count 0
Caught exception


-- 


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

Reply via email to