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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs