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

            Bug ID: 42796
           Summary: UBSan (enum) failure on <regex> implementation of MSVC
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

The following case is reduced from the std::regex_search() of MSVC2017.
Compiler explorer: https://godbolt.org/z/OZKIJV

// clang++ -std=c++2a -fsanitize=enum
enum E
{
    A = 1,
    B = 2,
    C = 4,
};

constexpr E operator&(E _Left, E _Right) noexcept 
        {
        return (static_cast<E>(static_cast<int>(_Left) &
static_cast<int>(_Right))); 
        } 

constexpr E operator~(E _Left) noexcept 
        {
        return (static_cast<E>(~static_cast<int>(_Left))); 
        } 

int main()
{
    E e = E::A;
    e = (e & ~E::C);
}

>> example.cpp:10:68: runtime error: load of value 4294967291, which is not a 
>> valid value for type 'E'

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