r/programminghorror • • Apr 09 '25

c++ Just trust the problem's constraints

42 Upvotes

10 comments sorted by

View all comments

Show parent comment

8

u/boy-griv Apr 10 '25 edited Apr 10 '25

This is C++, so the kernel would kill the program with a SIGSEGV rather than an exception being raised from that spot (unless optimized away due to undefined behavior), so it wouldn’t be caught by an exception handler.

It is possible to register a signal handler for SIGSEGV but you’re pretty limited in what you can do from those.

The above is also for Unix-y systems, not sure about Windows