Converting SIGSEGV signals to C++ exception in gcc/g++
David Hagood
david.hagood@gmail.com
Mon Aug 22 00:35:00 GMT 2011
On Sun, 2011-08-21 at 18:02 -0400, sudhakar govindavajhala wrote:
> Hi there,
>
> Is there a flag in compiling or using gcc/g++ so that a signal like
> SIGSEGV in my C++ program will result in an exception being thrown?
> If not, why not? I mean, is this is not a reasonable expectation in
> OOPS?
I've tried this with mixed results - write a POSIX signal handler, throw
an exception. Sometimes it works, sometimes it doesn't -0 the exception
goes sailing right past handlers that should have caught it and
terminate() gets called.
Part of the problem is that the compiler expects to have some clue where
exceptions can happen. Catching POSIX signals means an exception can
happen almost anywhere, and I don't think it works well with the
generated code.
But I'd be interested in hearing from others, as well.
More information about the Gcc-help
mailing list