<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Result of left-shifting an unsigned char is (promoted to?) signed."
   href="https://bugs.llvm.org/show_bug.cgi?id=52234">52234</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Result of left-shifting an unsigned char is (promoted to?) signed.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew@aitchison.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25378" name="attach_25378" title="c++ source that exhibits the problem">attachment 25378</a> <a href="attachment.cgi?id=25378&action=edit" title="c++ source that exhibits the problem">[details]</a></span>
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>