Answer the question
In order to leave comments, you need to log in
Try catch processing. What am I doing wrong?
I can't catch an exception and, accordingly, debug a C++ program...
try {
int a = 1, b = 0;
int c = a / b; // в данном случае имитирую exception для примера
}
catch (...) {
int a = 1;
}
Answer the question
In order to leave comments, you need to log in
division by 0 is not an exception, but an iron level error. You cannot intercept, you can process it by including the csignal header file and setting the handler for SIGFPE.
Specifically, the studio may have its own bike for intercepting such errors and converting them to an exception, but I won’t tell you where to set it up, it might be worth digging into Debug-> Exceptions
Perhaps the optimizer threw out code that does nothing.
put something in the exception handler with a side effect, like cout << "FAULT!" <<endl;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question