http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51921
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-02-10 23:35:15 UTC --- Here is a C++ example (which comes from PR 52205 which I marked as a dup of this bug): #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void die(const char* msg) { perror(msg); exit(EXIT_FAILURE); } void handler(int signo, siginfo_t* info, void *context) { printf("in handler signal %d\n", signo); throw signo; } int main(int, const char**) { struct sigaction act; memset(&act, 0, sizeof act); act.sa_sigaction = handler; sigfillset(&act.sa_mask); act.sa_flags = SA_SIGINFO; if (sigaction(SIGSEGV, &act, NULL) != 0) die("sigaction"); try { *reinterpret_cast<char*>(0) = 1; } catch (int signo) { printf("caught signal %d\n", signo); exit(EXIT_SUCCESS); } printf("did not catch\n"); exit(EXIT_FAILURE); }