<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;P0710R0</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Date:
     </TD>
<TD>
      &#160;2017-06-19</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="943"></A><H4>943.
  
Is <TT>T()</TT> a temporary?
</H4><B>Section: </B>8.2.3&#160; [expr.type.conv]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Miller
 &#160;&#160;&#160;

 <B>Date: </B>14 July, 2009


<P>According to 8.2.3 [expr.type.conv] paragraphs 1 and 3 (stated
directly or by reference to another section of the Standard), all the
following expressions create temporaries:</P>

<PRE>
    T(1)
    T(1, 2)
    T{1}
    T{}
</PRE>

<P>However, paragraph 2 says,</P>

<BLOCKQUOTE>

The expression <TT>T()</TT>, where <TT>T</TT> is a
<I>simple-type-specifier</I> or <I>typename-specifier</I> for a
non-array complete effective object type or the (possibly
cv-qualified) <TT>void</TT> type, creates an rvalue of the specified
type, which is value-initialized (11.6 [dcl.init]; no
initialization is done for the <TT>void()</TT> case).

</BLOCKQUOTE>

<P>This does <I>not</I> say that the result is a temporary, which
means that the lifetime of the result is not specified by
15.2 [class.temporary].  Presumably this is just an oversight.</P>

<P><B>Notes from the October, 2009 meeting:</B></P>

<P>The specification in 8.2.3 [expr.type.conv] is in error, not
because it fails to state that <TT>T()</TT> is a temporary but because
it requires a temporary for the other cases with fewer than two operands.
The case where <TT>T</TT> is a class type is covered by
15.2 [class.temporary] paragraph 1 (&#8220;a conversion that creates
an rvalue&#8221;), and a temporary should <I>not</I> be created when
<TT>T</TT> is not a class type.</P>

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

<P>This issue is resolved by the resolution of
issue 1299.</P>

<BR><BR><HR><A NAME="1076"></A><H4>1076.
  
Value categories and lvalue temporaries
</H4><B>Section: </B>6.10&#160; [basic.lval]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>2010-06-10


<P>The taxonomy of value categories in 6.10 [basic.lval]
classifies temporaries as prvalues.  However, some temporaries are
explicitly referred to as lvalues (cf 18.1 [except.throw]
paragraph 3).</P>

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

<P>This issue is resolved by the resolution of
issue 1299.</P>

<BR><BR><HR><A NAME="1299"></A><H4>1299.
  
&#8220;Temporary objects&#8221; vs &#8220;temporary expressions&#8221;
</H4><B>Section: </B>15.2&#160; [class.temporary]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Johannes Schaub
 &#160;&#160;&#160;

 <B>Date: </B>2011-04-16




<P>The Standard is insufficiently precise in dealing with temporaries.
It is not always clear when the term &#8220;temporary&#8221; is referring
to an expression whose result is a prvalue and when it is referring to
a temporary object.</P>

<P>(See also issue 1568.)</P>

<P><B>Proposed resolution (February, 2014) [SUPERSEDED]:</B></P>

<P>The resolution is contained in document N3918.</P>

<P>This resolution also resolves issues 1651
and 1893.</P>

<P><B>Additional note, November, 2014:</B></P>

<P>Concerns have been raised  that the meaning of
&#8220;corresponding temporary object&#8221; is not clear enough
in the proposed wording.  In addition, N3918 says that it
resolves issue 1300, but that issue
is 1) marked as a duplicate of issue 914
and 2) the subject of continuing deliberations in EWG.  This
issue is being returned to "review" status to allow CWG to
address these concerns.</P>

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

<OL><LI><P>Change 8 [expr] paragraph 12 as follows:</P></LI>

<BLOCKQUOTE>

...is applied. [<I>Note:</I> If the expression is an lvalue of
class type, it must have a volatile copy constructor to
initialize the temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN> that is the result
object of the lvalue-to-rvalue conversion.  &#8212;<I>end
note</I>] The glvalue expression...

</BLOCKQUOTE>

<LI><P>Change 15.2 [class.temporary] paragraph 6 as follows:</P></LI>

<BLOCKQUOTE>

<P>The third context is when a reference is bound to a
temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN>.<SUP>116</SUP> The
temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN> to which the reference is bound or
the temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN> that is the complete object of a
subobject to which the reference is bound persists for the
lifetime of the reference <SPAN style="font-weight:bold;background-color:#A0FFA0">if the glvalue referring to the
temporary object was obtained through one of the following:</SPAN></P>

<UL><LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a temporary materialization conversion
(7.4 [conv.rval]),</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0"><TT>(</TT> <I>expression</I> <TT>)</TT>,
where <I>expression</I> is one of these expressions,</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">subscripting (8.2.1 [expr.sub]) of an array
operand, where that operand is one of these expressions,</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a class member access (8.2.5 [expr.ref]) using
the <TT>.</TT> operator where the left operand is one of these
expressions and the right operand designates a non-static data member
of non-reference type,</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a pointer-to-member operation (8.5 [expr.mptr.oper])
using the <TT>.*</TT> operator where the left operand is one of these
expressions and the right operand is a pointer to data member of
non-reference type,</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a <TT>const_cast</TT> (8.2.11 [expr.const.cast],
<TT>static_cast</TT> (8.2.9 [expr.static.cast]),
<TT>dynamic_cast</TT> (8.2.7 [expr.dynamic.cast]), or
<TT>reinterpret_cast</TT> (8.2.10 [expr.reinterpret.cast]) converting
a glvalue operand that is one of these expressions to a glvalue
referring to that operand,</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a conditional expression (8.16 [expr.cond]) that
is a glvalue where the second or third operand is one of these
expressions, or</SPAN></P></LI>

<LI><P><SPAN style="font-weight:bold;background-color:#A0FFA0">a comma expression (8.19 [expr.comma]) that
is a glvalue where the right operand is one of these
expressions.</SPAN></P></LI>

</UL>

<P><SPAN style="font-weight:bold;background-color:#A0FFA0">[<I>Example:</I></SPAN></P>

<PRE>
<SPAN style="font-weight:bold;background-color:#A0FFA0">  template&lt;typename T&gt; using id = T;

  int&amp;&amp; a = id&lt;int[3]&gt;{1, 2, 3}[i];          //<SPAN style="font-family:Times;font-style:italic"> temporary array has same lifetime as</SPAN> a
  const int&amp; b = static_cast&lt;const int&amp;&gt;(0); //<SPAN style="font-family:Times;font-style:italic"> temporary </SPAN>int<SPAN style="font-family:Times;font-style:italic"> has same lifetime as</SPAN> b
  int&amp;&amp; c = cond ? id&lt;int[3]&gt;{1, 2, 3}[i] : static_cast&lt;int&amp;&amp;&gt;(0);
                                             //<SPAN style="font-family:Times;font-style:italic"> exactly one of the two temporaries is lifetime-extended</SPAN></SPAN>
</PRE>

<P><SPAN style="font-weight:bold;background-color:#A0FFA0">&#8212;<I>end example</I>] [<I>Note:</I> If a temporary object
has a reference member initialized by another temporary object,
lifetime extension applies recursively to such a member's initializer.
[<I>Example:</I></SPAN></P>

<PRE>
<SPAN style="font-weight:bold;background-color:#A0FFA0">  struct S {
    const int&amp; m;
  };
  const S&amp; s = S{1};  //<SPAN style="font-family:Times;font-style:italic"> both </SPAN>S<SPAN style="font-family:Times;font-style:italic"> and </SPAN>int<SPAN style="font-family:Times;font-style:italic"> temporaries have lifetime of</SPAN> s</SPAN>
</PRE>

<P><SPAN style="font-weight:bold;background-color:#A0FFA0">&#8212;<I>end example</I>] &#8212;<I>end note</I>]</SPAN></P>

<P><SPAN style="text-decoration:line-through;background-color:#FFA0A0">except</SPAN> <SPAN style="font-weight:bold;background-color:#A0FFA0">The exceptions to this lifetime rule
are</SPAN>:</P>

<UL><LI><P>A temporary object bound to a reference parameter...</P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Change 16.3.1.4 [over.match.copy] bullet 1.2 as follows:</P></LI>

<UL><LI><P>When the type of the initializer expression is a class
type &#8220;<I>cv</I> <TT>S</TT>&#8221;, the non-explicit
conversion functions of <TT>S</TT> and its base classes are
considered. When initializing a temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object
(12.2 [class.mem])</SPAN> to be bound to the first
parameter of a constructor...</P></LI>

</UL>

<LI><P>Change 20.5.4.9 [res.on.arguments] bullet 1.3 as follows:</P></LI>

<UL><LI><P>...[<I>Note:</I> If a program casts an lvalue to an xvalue while
passing that lvalue to a library function (e.g. by calling the
function with the argument std::move(x)), the program is
effectively asking that function to treat that lvalue as a
temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN>.  The implementation is free...</P></LI>

</UL>

<LI><P>Change 23.11.2.3.3 [util.smartptr.weak.assign] paragraph 2 as
follows:</P></LI>

<BLOCKQUOTE>

<I>Remarks</I>: The implementation may meet the effects (and the
implied guarantees) via different means, without creating a
temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN>.

</BLOCKQUOTE>

<LI><P>Change the footnote in 29.7.2.1 [template.valarray.overview]
paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...generalized subscript operators. [<I>Footnote:</I> The intent is
to specify an array template that hass the minimum functionality
necessary to address aliasing ambiguities and the proliferation of
<SPAN style="text-decoration:line-through;background-color:#FFA0A0">temporaries</SPAN> <SPAN style="font-weight:bold;background-color:#A0FFA0">temporary objects</SPAN>. Thus...
&#8212;<I>end footnote</I>]

</BLOCKQUOTE>

<LI><P>Change the last bullet of C.2.16 [diff.cpp03.input.output] as
follows:</P></LI>

<UL><LI><P>initializing a <TT>const bool &amp;</TT> which would bind
to a temporary <SPAN style="font-weight:bold;background-color:#A0FFA0">object</SPAN>.</P></LI>

</UL>

</OL>

<P>This resolution also resolves issues 943
and 1076.</P>

<BR><BR><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>
