<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2618</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="2618"></A><H4>2618.
  
Substitution during deduction should exclude exception specifications
</H4>
<B>Section: </B>13.10.3.1&#160; [<A href="https://wg21.link/temp.deduct.general">temp.deduct.general</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++23
 &#160;&#160;&#160;

 <B>Submitter: </B>Christof Meerwald
 &#160;&#160;&#160;

 <B>Date: </B>2021-11-27<BR>


<P>[Accepted as a DR at the November, 2022 meeting.]</P>

<P>Subclause 13.10.3.1 [<A href="https://wg21.link/temp.deduct.general#7">temp.deduct.general</A>] paragraph 7 specifies:</P>

<BLOCKQUOTE>

<P>
The substitution occurs in all types and expressions that are used in
the function type and in template parameter declarations. The
expressions include not only constant expressions such as those that
appear in array bounds or as nontype template arguments but also
general expressions (i.e., non-constant expressions) inside sizeof,
decltype, and other contexts that allow non-constant expressions. The
substitution proceeds in lexical order and stops when a condition that
causes deduction to fail is encountered. If substitution into
different declarations of the same function template would cause
template instantiations to occur in a different order or not at all,
the program is ill-formed; no diagnostic required.
</P>
<P>[<I>Note 4:</I> The equivalent substitution in exception
specifications is done only when the <I>noexcept-specifier</I> is
instantiated, at which point a program is ill-formed if the
substitution results in an invalid type or expression. &#8212;<I>end
note</I>]
</P>

</BLOCKQUOTE>

<P>The note says that substitution into the <I>noexcept-specifier</I>
occurs late, but the normative text does not support that, because the
exception specification is part of the function type.</P>

<P>Subclause 13.10.3.1 [<A href="https://wg21.link/temp.deduct.general#8">temp.deduct.general</A>] paragraph 8 specifies:</P>

<BLOCKQUOTE>

Only invalid types and expressions in the immediate context of the
function type, its template parameter types, and
its <I>explicit-specifier</I> can result in a deduction failure.

</BLOCKQUOTE>

<P>However, paragraph 7 does not mention the <I>explicit-specifier</I>
when describing the substitution.</P>

<P><B>Proposed resolution (approved by CWG 2022-09-09):</B></P>

<P>Change in 13.10.3.1 [<A href="https://wg21.link/temp.deduct.general#7">temp.deduct.general</A>] paragraph 7 as follows:</P>

<BLOCKQUOTE>

<P>
<INS>The <I>deduction substitution loci</I> are</INS>
<UL>
<LI><INS>the function type outside of the <I>noexcept-specifier</I>,</INS></LI>
<LI><INS>the <I>explicit-specifier</I>, and</INS></LI>
<LI>
<INS>the template parameter declarations</INS>.</LI>
</UL>
The substitution occurs in all types and expressions that are used in
the <DEL>function type and in template parameter declarations</DEL>
<INS>deduction substitution loci</INS>. ...
</P>

</BLOCKQUOTE>

<P>Change in 13.10.3.1 [<A href="https://wg21.link/temp.deduct.general#8">temp.deduct.general</A>] paragraph 8 as follows:</P>

<BLOCKQUOTE>
...
<DEL>Only invalid</DEL> <INS>Invalid</INS> types and
expressions <INS>can result in a deduction failure only</INS> in the
immediate context of the <DEL>function type, its template parameter
types, and its <I>explicit-specifier</I></DEL>
<INS>deduction substitution loci</INS> <DEL>can result in a deduction
failure</DEL>.

</BLOCKQUOTE>

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