Null pointer

Also, in languages offering such support, the correct use depends on the individual experience of each developer and linter tools.

Because a null pointer does not point to a meaningful object, an attempt to access the data stored at that (invalid) memory location may cause a run-time error or immediate program crash.

It is one of the most common types of software weaknesses,[1] and Tony Hoare, who introduced the concept, has referred to it as a "billion dollar mistake".

It is also possible for the compiler to optimize away the null pointer dereference, avoiding a segmentation fault but causing other undesired behavior.

[13] Bond et al.[13] suggest modifying the Java Virtual Machine (JVM) to keep track of null propagation.

User code running in interpreted or virtual-machine languages generally does not suffer the problem of null pointer dereferencing.

As a rule of thumb, for each type of struct or class, define some objects representing some state of the business logic replacing the undefined behaviour on null.

In 2009, Tony Hoare stated[17][18] that he invented the null reference in 1965 as part of the ALGOL W language.

At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W).

This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.