<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1186</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="1186"></A><H4>1186.
  
Non-dependent <TT>constexpr</TT> violations in function templates
</H4>
<B>Section: </B>9.2.6&#160; [<A href="https://wg21.link/dcl.constexpr">dcl.constexpr</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2010-08-30<BR>


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3262.]</P>

<P>9.2.6 [<A href="https://wg21.link/dcl.constexpr#5">dcl.constexpr</A>] paragraph 5 says,</P>

<BLOCKQUOTE>

If the instantiated template specialization of a constexpr function
template or member function of a class template would fail to satisfy
the requirements for a constexpr function or constexpr constructor,
that specialization is not a constexpr function or constexpr
constructor.  [<I>Note:</I> if the function is a member function it
will still be <TT>const</TT> as described below.  Implementations are
encouraged to issue a warning if a function is rendered not constexpr
by a non-dependent construct. &#8212;<I>end note</I>]

</BLOCKQUOTE>

<P>A non-dependent error in a function template renders it ill-formed
with no diagnostic required (13.8 [<A href="https://wg21.link/temp.res#8">temp.res</A>] paragraph 8).
A similar approach is being taken in the proposed resolution of
<A HREF="1125.html">issue 1125</A> with respect to constexpr
functions.  It would be more consistent to treat constexpr function
templates in the same way, along the lines of</P>

<BLOCKQUOTE>

If no specialization of the template would be <TT>constexpr</TT>,
the program is ill-formed, no diagnostic required.

</BLOCKQUOTE>

<P><B>Proposed resolution (November, 2010) [SUPERSEDED]:</B></P>

<P>Change 9.2.6 [<A href="https://wg21.link/dcl.constexpr#6">dcl.constexpr</A>] paragraph 6 as follows:</P>

<BLOCKQUOTE>

If the instantiated template specialization of a constexpr function
template or member function of a class template would fail to satisfy
the requirements for a <TT>constexpr</TT> function or
<TT>constexpr</TT> constructor, that specialization is not a
<TT>constexpr</TT> function or <TT>constexpr</TT> constructor.
[<I>Note:</I> if the function is a member function it will still be
<TT>const</TT> as described below.  <DEL>Implementations are
encouraged to issue a warning if a function is rendered not
<TT>constexpr</TT> by a non-dependent construct.</DEL> &#8212;<I>end
note</I>] <INS>If no specialization of the template would yield a
<TT>constexpr</TT> function or <TT>constexpr</TT> constructor, the
program is ill-formed; no diagnostic required.</INS>

</BLOCKQUOTE>

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