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: unassignedclangb...@nondot.org
          Reporter: mikhail.matro...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to