The answer to your question is in English SO. Here is a small translation of the best answer:
The fact is that according to the language standard, division by zero is not considered an exceptional situation, but it generates an error that is determined at the hardware level and returns back to the operating system, which then notifies your program in a specific OS in a specific way (for example, ending the process).
I believe that in this case, it is not an exception, but a signal. If so, the Operating System interrupts the main control flow of your program and calls the signal handler, which - in turn - terminates the program.
The same type of error occurs when you dereference a null pointer and your program crashes on a SIGSEGV signal, which causes a segmentation error.
You can use the functions from the <csignal> header to make a custom handler for the SIGFPE signal (which is used to exclude a floating-point number, but it can be used for integer division by zero - But in fact, I'm not very sure about that). However, it should be noted that signal processing is OS-dependent and MinGW somehow "emulates" POSIX signals in the Windows environment.
#include <csignal> #include <iostream> using namespace std; void handler(int a) { cout << "Signal " << a << " here!" << endl; } int main() { signal(SIGFPE, handler); int a = 1/0; }
conclusion
Signal 8 here!