<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Bad diagnostic on compile error in constant evaluation"
href="https://bugs.llvm.org/show_bug.cgi?id=43715">43715</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bad diagnostic on compile error in constant evaluation
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++17
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>barry.revzin@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>From stack overflow (<a href="https://stackoverflow.com/q/58454657/2069064">https://stackoverflow.com/q/58454657/2069064</a>):
constexpr int f(int n)
{
int r = n--;
for (; n > 1; --n) r *= n;
return r;
}
constexpr int x = f(13);
On clang trunk, with --std=c++17, this fails to compile (as expected), but the
error says (<a href="https://gcc.godbolt.org/z/2f15Qi">https://gcc.godbolt.org/z/2f15Qi</a>):
<source>:8:15: error: constexpr variable 'x' must be initialized by a constant
expression
constexpr int x = f(13);
^ ~~~~~
<source>:4:26: note: value 3113510400 is outside the range of representable
values of type 'int'
for (; n > 1; --n) r *= n;
^
<source>:8:19: note: in call to 'f(3)'
constexpr int x = f(13);
^
There's no call to f(3) in this program, but the diagnostic erroneously
references it.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>