https://bugs.llvm.org/show_bug.cgi?id=50711

            Bug ID: 50711
           Summary: Bug: undefined behavior of constexpr static_cast from
                    int to unscoped enum without fixed type outside range
                    compiles fine on C++17
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++17
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Hi,

The following code is undefined behavior in C++17. And undefined behavior is
not allowed in constant expressions - the compiler is required to diagnose it.
Adapted from cppreference:

enum foo { a = 0, b = 1 }; 
constexpr foo x = static_cast<foo>(123); // undefined behavior since C++17

However Clang happily compiles this code:

https://godbolt.org/z/bzhWMxqoE

-- 
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

Reply via email to