Hacker News new | ask | show | jobs
by kazinator 28 days ago
OK, so you are talking about running crypt() on bare metal microcontrollers or other small systems that don't have MMU support for trapping null pointers. Everywhere else, dereferencing an undisplaced null pointer is a instant CPU trap, even though it be formally undefined behavior in ISO C.

Note that even on systems that don't have hardware support for trapping null pointers, it can be implemented in the compiler as a code generation option.

For instance, in 1987, Microsoft Quick C introduced the /Zr option for doing this, as well as a #pragma check_pointer({on|off}).

If you're interested, BitSavers has the documentation: https://bitsavers.trailing-edge.com/pdf/microsoft/msdos_c/qu... Look for section 8.1.4.4 and also /Zr.