[llvm-bugs] [Bug 43714] New: consteval function allows undefined behavior
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 18 09:45:42 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43714
Bug ID: 43714
Summary: consteval function allows undefined behavior
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: mikhail.matrosov 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
Compile this program:
```
#include <iostream>
consteval int f(int n)
{
int r = n--;
for (; n > 1; --n) r *= n;
return r;
}
int main()
{
int x = f(13);
std::cout << x;
}
```
Expected: does not compile, since 13! overflows int (UB not allowed on compile
time)
Actual: compiles, runs with UB
Demo: https://wandbox.org/permlink/QJziECSrsDGuQyj4
See also: https://stackoverflow.com/q/58454657/261217
--
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/a0586d22/attachment.html>
More information about the llvm-bugs
mailing list