<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 804</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="804"></A><H4>804.
  
Deducing the type in <TT>new auto(x)</TT>
</H4>
<B>Section: </B>7.6.2.8&#160; [<A href="https://wg21.link/expr.new">expr.new</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>3 March, 2009<BR><BR>


<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#UK71">N2800 comment
  UK&#160;71<BR></A>

<P>[Voted into WP at October, 2009 meeting.]</P>

<P>
The type of an allocated object wih the
type specifier <TT>auto</TT> is determined by the rules of copy
initialization, but the initialization applied will be
direct initialization. This would affect classes which
declare their copy constructor explicit, for instance. For
consistency, use the same form of initiailization for the
deduction as the new expression.
</P>

<P><B>Proposed resolution (July, 2009):</B></P>

<P>Change 7.6.2.8 [<A href="https://wg21.link/expr.new#2">expr.new</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

<P>If the <TT>auto</TT> <I>type-specifier</I> appears in the
<I>type-specifier-seq</I> of a <I>new-type-id</I> or <I>type-id</I> of a
<I>new-expression</I>, the <I>new-expression</I> shall contain a
<I>new-initializer</I> of the form</P>

<UL>
<TT>(</TT> <I>assignment-expression</I> <TT>)</TT>
</UL>

<P>The allocated type is deduced from the <I>new-initializer</I> as
follows: Let <DEL><TT>(e)</TT> be</DEL> <INS><TT>e</TT> be the
<I>assignment-expression</I> in</INS> the <I>new-initializer</I> and
<TT>T</TT> be the <I>new-type-id</I> or <I>type-id</I> of the
<I>new-expression</I>, then the allocated type is the type deduced for
the variable <TT>x</TT> in the invented declaration (9.2.9.7 [<A href="https://wg21.link/dcl.spec.auto">dcl.spec.auto</A>]):</P>

<UL><TT>T <DEL>x = e</DEL> <INS>x(e)</INS>;</TT></UL>

<P>[<I>Example:</I>...</P>

</BLOCKQUOTE>

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