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: unassignedclangb...@nondot.org
          Reporter: aa...@aaronballman.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

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
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to