C++ Undefined Behavior Reading or writing through a null pointer


Example

int *ptr = nullptr;
*ptr = 1; // Undefined behavior

This is undefined behavior, because a null pointer does not point to any valid object, so there is no object at *ptr to write to.

Although this most often causes a segmentation fault, it is undefined and anything can happen.