<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 - Incorrect clang warning -Wconstant-conversion on unsigned types"
   href="https://bugs.llvm.org/show_bug.cgi?id=37771">37771</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect clang warning -Wconstant-conversion on unsigned types
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>manojgupta@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, rtrieu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Found when building Linux kernel 4.14 with clang:
(<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=849780">https://bugs.chromium.org/p/chromium/issues/detail?id=849780</a>).

Reduced test cases:

unsigned char test_char(void)
{
  const unsigned char w = 128;

  return ~w;
}

../build/char_warn.c:5:10: error: implicit conversion from 'int' to 'unsigned
char' changes value from -129 to 127
      [-Werror,-Wconstant-conversion]
  return ~w;


unsigned short test_short(void)
{
  const unsigned short w = 0x8000;

  return ~w;
}

../build/short_warn.c:5:10: error: implicit conversion from 'int' to 'unsigned
short' changes value from -32769 to 32767
      [-Werror,-Wconstant-conversion]
  return ~w;</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>