Reading or writing through a null pointer

suggest change
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.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents