[llvm-bugs] [Bug 24948] New: enum types defined by CF_ENUM cannot be used as numeric values in C++11

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 26 07:04:03 PDT 2015


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

            Bug ID: 24948
           Summary: enum types defined by CF_ENUM cannot be used as
                    numeric values in C++11
           Product: clang
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 191919 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code (assuming it is saved as `1.mm`)

```
#import <Foundation/Foundation.h>

typedef CF_ENUM(uint64_t, MyEnum) {
    kFirstBit = 0,
    kSecondBit = 1,
    kThirdBit = 2
};

int main() {
    MyEnum e = kFirstBit | kSecondBit;
}

```

was compilable by clang 3.6 but cannot in clang 3.7/3.8svn with C++11 mode.

$ clang++ -o 1.o 1.mm        # succeeded

$ clang++ -std=c++11 -o 1.o 1.mm 

1.mm:11:9: error: cannot initialize a variable of type 'MyEnum' with an rvalue
of type 'unsigned long long'
        MyEnum e = kFirstBit | kSecondBit;
               ^   ~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

MyEnum was regarded as strong enum by -std=c++11.

This change of behavior makes a lot of codes cannot be compiled as
Objective-C++ in C++11 mode.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150926/15b9eb0f/attachment-0001.html>


More information about the llvm-bugs mailing list