Well, I read it up in the 98 standard, and it doesn't mean
what I expected it to. It doesn't seem to be defined for the
storage for non-PODs at all, only for PODs. What the standard
calls "zero initializing the storage for an object", I would
have called "zero initializing an object", separating storage
(raw memory, for which "zero initializing" means setting all
bits to 0), and objects (for which "zero initializing" means
giving it the type's representation of the zero value).
Apparently, the text in C++98 didn't satisfy the committee,
either, since it got reworked in C++03. The basic idea was,
however, for an object with dynamic initialization to be
initialized as if it had no explicit initializer in C. Thus,
pointers are null, int's 0, doubles 0.0, etc. It's somewhat
difficult to formulate, however, because C++ has other types of
objects as well.
That's what I would have expected though. But if that wasn't
meant, what was?
More or less:
in a composite object (class or array), each of the
component parts is zero initialized, recursively, until you
reach a non-composite object,
for unions, the first member is zero initialized,
for pointers (including pointers to members) and arithmetic
types, zero initialization is the equivalent of initializing
with a 0, converted to the appropriate type, and
for references and internal data, nothing (you can't
initialize a reference with 0, and you can't legally do
anything which would require internal data, like the vptr,
until dynamic initialization runs).
Except for the bit about references, the rules above are those
of C. In particular, pointers are initialized with a null
pointer (not with all bits 0), and floating point with 0.0
(which formally may not have all bits 0, although I've never
heard of a case where it was otherwise). And in something like:
union { char* a; char b[10000] ; } ;
only the element a is initialized (as a null pointer, which
might mean that b[0] != 0).
I just find it strange that the object is said to be
initialzed twice.
It is. But it's a very special kind of initialization. And
since it definitly takes type information into account, I don't
know what else you'd call it.