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

            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: unassignedb...@nondot.org
          Reporter: and...@aitchison.me.uk
                CC: htmldevelo...@gmail.com, llvm-bugs@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
  signed_shifts.cpp
with
  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
21.10
I get 
  error: implicit conversion changes signedness: 'int' to 'unsigned int'
[-Werror,-Wsign-conversion]

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

Reply via email to