cpp/language/zero initialization

Sets the initial value of an object to zero.

Syntax
Note that this is not the syntax for zero-initialization, which does not have a dedicated syntax in the language. These are examples of other types of initializations, which might perform zero-initialization.

Explanation
Zero-initialization is performed in the following situations: @1@ For every named variable with static that is not subject to, before any other initialization. @2@ As part of sequence for non-class types and for members of value-initialized class types that have no constructors, including value initialization of elements of  for which no initializers are provided. @3@ When an array of any is  that is too short, the remainder of the array is zero-initialized.

The effects of zero-initialization are:
 * If is a scalar type, the object is initialized to the value obtained by  the integer literal  (zero) to.
 * If is a non-union class type:
 * all are initialized to zero bits,
 * each non-static is zero-initialized,
 * each non-virtual base class is zero-initialized, and
 * if the object is not a base class subobject, each subobject is zero-initialized.


 * If is a union type:
 * all padding bits are initialized to zero bits, and
 * the object’s first non-static named data member is zero-initialized.


 * If is array type, each element is zero-initialized.
 * If is reference type, nothing is done.