[llvm-bugs] [Bug 43715] New: Bad diagnostic on compile error in constant evaluation
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 18 10:19:26 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43715
Bug ID: 43715
Summary: Bad diagnostic on compile error in constant evaluation
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: barry.revzin at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
>From stack overflow (https://stackoverflow.com/q/58454657/2069064):
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 (https://gcc.godbolt.org/z/2f15Qi):
<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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191018/38896514/attachment.html>
More information about the llvm-bugs
mailing list