[llvm-bugs] [Bug 34692] New: Enumeration with fixed unsigned underlying type erroneously triggers -Wsign-conversion

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 21 07:55:06 PDT 2017


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

            Bug ID: 34692
           Summary: Enumeration with fixed unsigned underlying type
                    erroneously triggers -Wsign-conversion
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hans.ellegard at crunchfish.com
                CC: llvm-bugs at lists.llvm.org

Fixing the underlying type of an enumeration to an unsigned char triggers the
"sign-conversion" warning when implicitly converting an instance of the
enumeration to unsigned int.

code snippet (func.cc):

unsigned int func();
unsigned int func() {
    enum u8 : unsigned char;
    u8 foo{static_cast<u8>(0)};
    return foo;
}

Clang output:

clang++ -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -std=c++11 -c
-o func.o func.cc
func.cc:5:10: warning: implicit conversion changes signedness: 'u8' to
'unsigned int' [-Wsign-conversion]
  return foo;
  ~~~~~~ ^~~
1 warning generated.

Here's a Godbolt link for it:
https://godbolt.org/g/s2wwMo

-- 
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/20170921/c5378dfa/attachment.html>


More information about the llvm-bugs mailing list