<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 530</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="530"></A><H4>530.
  
Nontype template arguments in constant expressions
</H4>
<B>Section: </B>7.7&#160; [<A href="https://wg21.link/expr.const">expr.const</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mark Mitchell
 &#160;&#160;&#160;

 <B>Date: </B>21 August 2005<BR>


<P>[Voted into the WP at the April, 2007 meeting as part of paper
J16/07-0095 = WG21 N2235.]</P>

<P>Consider:</P>

<PRE>
    template &lt;int* p&gt; struct S {
        static const int I = 3;
    };
    int i;
    int a[S&lt;&amp;i&gt;::I];
</PRE>

<P>Clearly this should be valid, but a pedantic reading of
7.7 [<A href="https://wg21.link/expr.const">expr.const</A>] would suggest that this is invalid because
&#8220;<TT>&amp;i</TT>&#8221; is not permitted in integral constant
expressions.</P>

<P><B>Proposed resolution (October, 2005):</B></P>

<P>Change the last sentence of 7.7 [<A href="https://wg21.link/expr.const#1">expr.const</A>] paragraph 1
as indicated:</P>

<BLOCKQUOTE>

In particular, except in <INS>non-type <I>template-argument</I>s
or</INS> <TT>sizeof</TT> expressions, functions, class objects,
pointers, or references shall not be used, and assignment, increment,
decrement, function-call, or comma operators shall not be used.

</BLOCKQUOTE>

<P><I>(Note: the same text is changed by the resolution of
<A HREF="367.html">issue 367</A>.)</I></P>

<P><B>Notes from April, 2006 meeting:</B></P>

<P>The proposed resolution could potentially be read as saying that
the prohibited operations and operators would be permitted in integral
constant expressions that are non-type <I>template-argument</I>s.  John
Spicer is investigating an alternate approach, to say that expressions
in non-type template arguments are not part of the expression in which
the <I>template-id</I> appears (in contrast to the operand of
<TT>sizeof</TT>, which is part of the containing expression).</P>

<P><B>Additional note (May, 2008):</B></P>

<P>This issue is resolved by the rewrite of 7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]
that was done in conjunction with the constexpr proposal, paper
N2235.</P>

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