Mike Wahler:
Not one which has never been initialized or assigned.
I think that's what OP is asking about.
Okey dokey, start from the basics:
If you don't initialise an object of intrinsic type, then it contains
garbage. Sometimes it may contain a random, yet valid, value. Other times,
it may contain a value which will cause chaos when you try to interpret it
(this is known as trapping).
Neglecting to initialise a pointer variable is exactly the same as
neglecting to initialise an int, or a double, or a bool. It has an
indeterminant value. The value it contains may be null, or it may be a
random yet valid value, or it may be a random and invalid value.
If a pointer did not get its value through legitimate means, then you can't
expect it to do anything for you. You can't expect it to tell you whether
it's null. You can't expect it to tell you whether it points to an actual
object.
So to answer the question: The C++ Standard provides no means by which to
confirm the validity or nullness of a misused pointer. If you want such a
safety net, then write a class:
class Ptr {
public:
bool IsValid() const { ... }
}
, just don't expect any proficient programmer to agree with you.