[llvm-bugs] [Bug 28425] New: Compile failure with enum and ternary operator

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 5 07:56:23 PDT 2016


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

            Bug ID: 28425
           Summary: Compile failure with enum and ternary operator
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: peter.klotz99 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16693
  --> https://llvm.org/bugs/attachment.cgi?id=16693&action=edit
Program that demonstrates the behavior

clang fails to compile the attached (rather simple) C++ program.

[user at host test]$ clang++ -Wall -Wextra -c clang_error.cpp
clang_error.cpp:11:28: error: cannot initialize a variable of type 'const
PermissionTypePk' with an rvalue of type 'int'
    const PermissionTypePk permissionTypePk = true ?
PermissionType::getPermissionType().m_pk : PT_GLOBAL;
                           ^                 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Removing "const" from member "m_pk" makes the program compile.

gcc 6 compiles both versions, with and without "const".

-- 
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/20160705/8468dbd1/attachment.html>


More information about the llvm-bugs mailing list