<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1537</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="1537"></A><H4>1537.
  
Optional compile-time evaluation of 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>CD3
 &#160;&#160;&#160;

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>2012-08-14<BR>


<P>[Moved to DR at the April, 2013 meeting.]</P>

<P>According to the note in 7.7 [<A href="https://wg21.link/expr.const#4">expr.const</A>] paragraph 4,</P>

<BLOCKQUOTE>

[<I>Note:</I> Although in some contexts constant expressions must be
evaluated during program translation, others may be evaluated during
program execution. Since this International Standard imposes no
restrictions on the accuracy of floating-point operations, it is
unspecified whether the evaluation of a floating-point expression
during translation yields the same result as the evaluation of the
same expression (or the same operations on the same values) during
program execution.

</BLOCKQUOTE>

<P>With the advent of narrowing rules, which require the compiler to
evaluate constant expressions in more contexts than was the case in
C++03 in order to determine whether an expression is well formed or
not, this wording is not sufficiently clear in stating that even in
cases where the computation must be done at compile time, the
implementation is free to use the result of a runtime calculation
rather than preserving the one computed at compile time.</P>

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

<P>Change 7.7 [<A href="https://wg21.link/expr.const#4">expr.const</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

[<I>Note:</I> <DEL>Although in some contexts constant expressions must
be evaluated during program translation, others may be evaluated
during program execution.</DEL> Since this International Standard
imposes no restrictions on the accuracy of floating-point operations,
it is unspecified whether the evaluation of a floating-point
expression during translation yields the same result as the evaluation
of the same expression (or the same operations on the same values)
during program execution. [<I>Footnote:</I> Nonetheless,
implementations are encouraged to provide consistent results,
irrespective of whether the evaluation was <DEL>actually</DEL>
performed during translation <INS>and/</INS>or during program
execution. &#8212;<I>end footnote</I>] [<I>Example:</I>...

</BLOCKQUOTE>

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