Thanks Daved,


Yes, we can not distinguish with uninitialized and zero initialized, if uninitialized is 0. :-)

What I want to discuss is more about how Spec regulates it, from Spec,

http://www.codeguru.com/forum/showth...87&postcount=9

Seems it is regualated in Spec it should be zero initialized for POD, right?

Quote Originally Posted by Daved View Post
The question is probably how can you tell if a POD type has been zero-initialized.

The answer is you can't really for sure. You can check to see if it is zero, but an uninitialized value can often be zero as well.

Thanks CornedBee,


You mean both statements will make variable t undefined values?

Quote Originally Posted by CornedBee View Post
Which part of "does nothing" was too hard to understand? A default-initialized POD has an unspecified value. Reading it invokes undefined behaviour.

The subtlety here comes not from what the default constructor does, but from when a POD is default-constructed, and when it is value-initialized. Value-initialization of PODs leads to zero-initialization.

T t;
Default-constructs t. If it's a POD, the value is unspecified.

T t = T();
Default-constructs a T, and copies it to t. If T is a POD, this default-construction leads to value-initialization.

regards,
George