This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Voted into the WP at the November, 2010 meeting.]
The C committee is considering changing the definition ofzero-initialization of unions to guarantee that the bytes of theentire union are set to zero before assigning 0, converted to theappropriate type, to the first member. The argument (summarizedhere)is for backward compatibility. The C++ Committee may want toconsider the same change.
Proposed resolution (August, 2008):
Change bullet 3 of 9.5 [dcl.init] paragraph 5 (in the firstlist, dealing with zero-initialization) as follows:
[Drafting notes: Ask a C liaison about the progress of WG14paper N1311, which deals with this issue. Since the adoption ofWG21 paper N2544, unions may have static data members, hence thechange to refer to the first non-static data member and thedeletion of the footnote.]
Notes from the September, 2008 meeting:
It was observed that padding bytes in structs arezero-initialized in C, so if we are changing the treatment ofunions in this way we should consider adding the C behavior forpadding bytes at the same time. In particular, usingmemcmp to compare structs only works reliably if thepadding bytes are zero-initialized.
Additional notes (February, 2010):
The C Committee has changed its approach to this question andis no longer using a two-phase process; in C, zero-initializationis specific to program start-up and thus is not appropriate foruse with thread-local storage. See C paperN1387.
Proposed resolution (October, 2010):
Change 9.5 [dcl.init] paragraph 5 as follows:
Tozero-initialize an object or reference of typeTmeans:
ifT is a scalar type (6.9 [basic.types]),the object is set to the value0 (zero), taken as an integralconstant expression, converted toT;103
if T is a (possibly cv-qualified) non-union class type, eachnon-static data member and each base-class subobject iszero-initialized, and padding is initialized to zero bits;
if T is a (possibly cv-qualified) union type, the object'sfirst non-static named data member is zero-initialized, and paddingis initialized to zero bits;
if T is an array type, each element is zero-initialized;
if T is a reference type, no initialization is performed.