See the code below. I run the code in windows 10, visual studio platform. The throw 1 can be caught in debug mode, but the throw failed in release mode with an error message "Unhandled exception at 0x00007FFC76DAA859: Microsoft C++ exception: int at memory location 0x000000D6464FF730". Any suggestions or comments are appreciated!
void MySignalHandler(int sig) {
if (sig == SIGILL) {
throw 1;
}
else {
std::cerr << "Unknown signal code received.\n";
}
}
int main() {
signal(SIGILL, MySignalHandler); // install SIGILL handler
int result = 1;
try {
raise(SIGILL);
}
catch (int i) {
result = 0;
}
return result;
}