I did this test to see what happened:
try { int *x = 0; *x = 1234; } catch(...) { cout << "OK"; }
But it throws a segfault, why does it not catch the segfault?
No you can`t.
A SEGFAULT isn't a regular exception.
SEGFAULT
The code you show is simply undefined behavior, and anything may be happen. There's no guarantee it ends up throwing an exception.
1.4m articles
1.4m replys
5 comments
57.0k users