News for hackers. Stuff that matters.
Re:Add detailed message to NullPointerException describing w... by int_19h on Tuesday March 26, 2019 @11:13PM (#19497903)
The standard is U.B., so throwing is a valid response.

On Win32, a segfault / access violation - and similar low-level errors, like division by zero - is represented as something called "structured exception". These have a standard OS ABI such that they can be caught, and stack can be unwound, across different languages.

In MSVC, normally, they are not treated as C++ exceptions for the purpose of catching them, although it will still participate in stack unwinding (if something else below is catching them). However, there is an opt-in compiler switch that does make them look like C++ exceptions in a sense that catch(...) will catch them. It's not something you'll see in most code written in the past 15 years or so, for obvious reasons.

There are no comments on this comment yet.