The C++ standard says (8.5/5):
To default-initialize an object of type
T
means:
If
T
is a non-POD class type (clause 9), the default constructor forT
is called (and the initialization is ill-formed ifT
has no accessible default constructor).If
T
is an array type, each element is default-initialized.Otherwise, the object is zero-initialized.
With this code
struct Int { int i; };
int main()
{
Int a;
}
the object a
is default-initialized, but clearly a.i
is not necessarily equal to 0 . Doesn't that contradict the standard, as Int
is POD and is not an array ?
Edit Changed from class
to struct
so that Int
is a POD.