<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    Core "ready" Issues
   </TITLE>
</HEAD>
<BODY>
<TABLE ALIGN="RIGHT" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ALIGN="RIGHT">
      Document number:
     </TD>
<TD>
       &#160;P0710R1</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Date:
     </TD>
<TD>
      &#160;2017-07-13</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Project:
     </TD>
<TD>
      &#160;Programming Language C++
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reference:
     </TD>
<TD>
      &#160;ISO/IEC IS 14882:2014
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reply to:
     </TD>
<TD>
      &#160;William M. Miller
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;Edison Design Group, Inc.
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;<A HREF="mailto://wmm@edg.com">wmm@edg.com</A></TD>
</TR>
</TABLE><BR CLEAR="ALL"><BR><CENTER>
<H2>
     Core Language Working Group "ready" Issues
     for the
     July, 2017 (Toronto) meeting
    </H2>
</CENTER><BR><P>
    Section references in this document reflect the section numbering
    of document
    <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf">WG21 N4659</A>.
   </P>
<HR><A NAME="2253"></A><H4>2253.
  
Unnamed bit-fields and zero-initialization
</H4><B>Section: </B>12.2.4&#160; [class.bit]
 &#160;&#160;&#160;

 <B>Status: </B>ready
 &#160;&#160;&#160;

 <B>Submitter: </B>Aaron Ballman
 &#160;&#160;&#160;

 <B>Date: </B>2016-03-23




<P>The current wording of the Standard does not clearly state that
zero-initialization applies to unnamed bit-fields.</P>

<P><B>Notes from the December, 2016 teleconference:</B>
</P>

<P>The consensus was that unnamed bit-fields do constitute padding;
more generally, padding should be normatively defined, along the lines
suggested in 12.2.4 [class.bit] paragraphs 1-2.</P>

<P><B>Proposed resolution (March, 2017):</B></P>

<OL><LI><P>Change 6.9 [basic.types] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

The <I>object representation</I> of an object of type <TT>T</TT> is the
sequence of <I>N</I> <TT>unsigned char</TT> objects taken up by the object
of type <TT>T</TT>, where <I>N</I> equals <TT>sizeof(T)</TT>. The <I>value
representation</I> of an object is the set of bits that hold the value of
type <TT>T</TT>. <SPAN style="font-weight:bold;background-color:#A0FFA0">Bits in the object representation that are not part
of the value representation are <I>padding bits</I>.</SPAN> For trivially
copyable types, the value representation is a set of bits in the object
representation that determines a <I>value</I>, which is one discrete
element of an implementation-defined set of values.<SUP>44</SUP>

</BLOCKQUOTE>

<LI><P>Change 11.6 [dcl.init] paragraph 6 as follows:</P></LI>

<BLOCKQUOTE>

<P>To <I>zero-initialize</I> an object or reference of type <TT>T</TT>
means:</P>

<UL><LI><P>if <TT>T</TT> is a scalar type (6.9 [basic.types]), the
object is initialized to the value obtained by converting the integer
literal <TT>0</TT> (zero) to <TT>T</TT>;<SUP>103</SUP></P></LI>

<LI><P>if <TT>T</TT> is a (possibly cv-qualified) non-union class type,
<SPAN style="font-weight:bold;background-color:#A0FFA0">its padding bits are initialized to zero bits and</SPAN> each
non-static data member and each base-class subobject is
zero-initialized<SPAN style="text-decoration:line-through;background-color:#FFA0A0"> and padding is initialized to zero
bits</SPAN>;</P></LI>

<LI><P>if <TT>T</TT> is a (possibly cv-qualified) union type, <SPAN style="font-weight:bold;background-color:#A0FFA0">its
padding bits are initialized to zero bits and</SPAN> the object's first
non-static named data member is zero-initialized<SPAN style="text-decoration:line-through;background-color:#FFA0A0"> and padding is
initialized to zero bits</SPAN>;</P></LI>

<LI><P>...</P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Change 12.2.4 [class.bit] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...The <I>constant-expression</I> shall be an integral constant expression
with a value greater than or equal to zero. The value of the integral
constant expression may be larger than the number of bits in the object
representation (6.9 [basic.types]) of the bit-field's type; in such
cases the extra bits are <SPAN style="text-decoration:line-through;background-color:#FFA0A0">used as</SPAN> padding
bits <SPAN style="font-weight:bold;background-color:#A0FFA0">(6.9 [basic.types])</SPAN><SPAN style="text-decoration:line-through;background-color:#FFA0A0">and do not participate in
the value representation (6.9 [basic.types]) of the
bit-field</SPAN>. Allocation of bit-fields...

</BLOCKQUOTE>

<LI><P>Change 6.9.1 [basic.fundamental] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...For narrow character types, all bits of the object representation
participate in the value representation. [<I>Note:</I> A bit-field of
narrow character type whose length is larger than the number of bits in the
object representation of that type has padding bits; see
<SPAN style="text-decoration:line-through;background-color:#FFA0A0">12.2.4 [class.bit]</SPAN>
<SPAN style="font-weight:bold;background-color:#A0FFA0">6.9 [basic.types]</SPAN>. &#8212;<I>end note</I>] For unsigned
narrow character types...

</BLOCKQUOTE>

</OL>

<BR><BR></BODY>
</HTML>
