with fixed PR26208 we can throw exceptions from signal handlers. catch() works pretty fine with complex call-chain but fails on simple testcase.
#include <csignal> void signalHandler( int signalNumber ) { throw 0; } int main() { signal( SIGSEGV, signalHandler ); try { int* p = 0; *p = 0; } catch ( int ) { } return 0; } $ g++ throw_from_sighandler.cpp -O1 --save-temps && ./a.out terminate called after throwing an instance of 'int' zsh: abort ./a.out main: subq $8, %rsp movl $_Z13signalHandleri, %esi movl $11, %edi call signal movl $0, 0 movl $0, %eax addq $8, %rsp ret -- Summary: try/catch block removed. too optimistic optimization? Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC target triplet: x86-64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28917