[llvm-bugs] [Bug 52234] New: Result of left-shifting an unsigned char is (promoted to?) signed.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 20 08:34:18 PDT 2021


            Bug ID: 52234
           Summary: Result of left-shifting an unsigned char is (promoted
                    to?) signed.
           Product: new-bugs
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: andrew at aitchison.me.uk
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 25378
  --> https://bugs.llvm.org/attachment.cgi?id=25378&action=edit
c++ source that exhibits the problem

Compile the attached source
  clang++ -Wsign-conversion -Werror -c -o signed_shifts.o signed_shifts.cpp

With clang++9, clang++-11, clang++-12 or clang++-13, as supplied by Ubuntu
I get 
  error: implicit conversion changes signedness: 'int' to 'unsigned int'

when an unsigned char is left-shifted and stored in an unsigned int,
unless the result is explicitly cast back to unsigned.

I also see this with gnu g++4,5,6,7,8,9 (9.4.0-3ubuntu1)
but not g++-10 (10.3.0-11ubuntu1 or g++-11 11.2.0-7ubuntu2.

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/20211020/75c88459/attachment.html>

More information about the llvm-bugs mailing list