Where exactly does C++ standard say dereferencing an uninitialized pointer is undefined behavior?

Section 4.1 looks like a candidate (emphasis mine):

An lvalue (3.10) of a
non-function, non-array type T can be
converted to an rvalue. If T is an
incomplete type, a program that
necessitates this conversion is
ill-formed. If the object to which the
lvalue refers is not an object of type
T and is not an object of a type
derived from T, or if the object is
uninitialized
, a program that
necessitates this conversion has
undefined behavior
. If T is a
non-class type, the type of the rvalue
is the cv-unqualified version of T.
Otherwise, the type of the rvalue is
T.

I’m sure just searching on “uninitial” in the spec can find you more candidates.

Leave a Comment