About exception
-
Hi
I am testing try / catch
so I coded as belowint a = 100, b = 0; try { int c = a/b; } catch (...) { qDebug() << "error A"; }
When I am debuging that code, An excption occurred in "int c = a/b;"
but it didnot go inside the catch statement.
the excepton message is as followsHow do I make the program go into a catch statement when an exception occurs in a try statement?
-
@qt_learning
You need to check it yourself and throw an exception. Integer divide by zero is not an exception in standard C++, its still "undefined behaviour" -
@qt_learning
https://stackoverflow.com/questions/6121623/catching-exception-divide-by-zero@J-Hilk
I think https://stackoverflow.com/a/26315860/489865 is saying MSVC (only) has a/EHa
option for extended exceptions? -
@JonB said in About exception:
/EHa
What /EHa does is chaniging the definition of an exception, extending it, wrapping system level errors as exceptions. This is non-standard and AFAIK MSVC specific.
I would stay as far away from it as possible.