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

            Bug ID: 47055
           Summary: Incorrect codegen for enum with bool underlying type
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Consider the following code that appears to be valid C++11:

enum E : bool { Zero, One };

int f(int x) {
  return (E)x;
}

Generates the following at -O0:

f(int):                                  # @f(int)
        push    rbp
        mov     rbp, rsp
        mov     dword ptr [rbp - 4], edi
        mov     eax, dword ptr [rbp - 4]
        and     al, 1
        movzx   eax, al
        pop     rbp
        ret

We are ANDing x with 0x1 rather than comparing it against zero as required by
[conv.bool] and [expr.static.cast]p10.

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