There are many questions on Stack Overflow that explain that the following is undefined behavior in C++:
MyType* p = nullptr;
p->DoSomething();
but I can't find one that cites the C++ standard. Which part of the C++11 and/or C++14 standards say that this is undefined behavior?
C++14 [expr.ref]/2:
C++14 [expr.unary.op]/1:
The pointer does not point to an object, therefore this quote does not define the behaviour of
*p
. Nowhere else in the standard defines it either, so it is undefined behaviour.Regarding whether a null pointer can be said to point to an object, N4618 [basic.compound]/3 defines pointer values as:
which indicates that the null pointer value does not point to an object.