<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1646</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="1646"></A><H4>1646.
  
<I>decltype-specifier</I>s, abstract classes, and deduction failure
</H4>
<B>Section: </B>7.6.1.3&#160; [<A href="https://wg21.link/expr.call">expr.call</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2013-03-28<BR>


<P>[Adopted at the June, 2018 meeting as part of paper P0929R2.]</P>



<P>According to 7.6.1.3 [<A href="https://wg21.link/expr.call#11">expr.call</A>] paragraph 11,</P>

<BLOCKQUOTE>

<P>If a function call is a prvalue of object type:</P>

<UL>
<LI><P>if the function call is either</P></LI>

<UL>
<LI><P>the operand of a <I>decltype-specifier</I> or</P></LI>

<LI><P>the right operand of a comma operator that is the operand of
a <I>decltype-specifier</I>,</P></LI>

</UL>

<P>a temporary object is not introduced for the prvalue. The
type of the prvalue may be incomplete.  [<I>Note:</I> as a
result, storage is not allocated for the prvalue and it is
not destroyed; thus, a class type is not instantiated as a
result of being the type of a function call in this
context. This is true regardless of whether the expression
uses function call notation or operator notation
(12.2.2.3 [<A href="https://wg21.link/over.match.oper">over.match.oper</A>]). &#8212;<I>end note</I>]
[<I>Note:</I> unlike the rule for
a <I>decltype-specifier</I> that considers whether
an <I>id-expression</I> is parenthesized
(9.2.9.3 [<A href="https://wg21.link/dcl.type.simple">dcl.type.simple</A>]), parentheses have no special
meaning in this context. &#8212;<I>end note</I>]</P>

<LI>

<P>otherwise, the type of the prvalue shall be complete.</P>
</LI>

</UL>

</BLOCKQUOTE>

<P>Thus, an example like</P>

<PRE>
  template &lt;class T&gt; struct A: T { };
  template &lt;class T&gt; A&lt;T&gt; f(T) { return A&lt;T&gt;(); };
  decltype(f(42)) *p;
</PRE>

<P>is well-formed.  However, a function template specialization in
which the return type is an abstract class should be a deduction
failure, per 13.10.3 [<A href="https://wg21.link/temp.deduct#8">temp.deduct</A>] paragraph 8, last bullet:</P>

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

<LI><P>Attempting to create a function type in which a parameter
type or the return type is an abstract class type
(11.7.4 [<A href="https://wg21.link/class.abstract">class.abstract</A>]).</P></LI>

</UL>

<P>The requirement that the return type in a function call in a
<I>decltype-specifier</I> not be instantiated prevents the detection
of this deduction failure in an example like:</P>

<PRE>
  template &lt;class T&gt; struct A { virtual void f() = 0; };
  template &lt;class T&gt; A&lt;T&gt; f(T) { return A&lt;T&gt;(); };
  decltype(f(42)) *p;
</PRE>

<P>It is not clear how this should be resolved.</P>

<P>(See also <A HREF="1640.html">issue 1640</A>.)</P>

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