<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 - Undetected UB of shift operator with Clang 14"
   href="https://bugs.llvm.org/show_bug.cgi?id=52079">52079</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Undetected UB of shift operator with Clang 14
          </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>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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>k.even-mendoza@imperial.ac.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This code example contains undetected UB with Clang 14 (also older versions):
int main() {
  if (0 << 2 % (short)((int)6503265032 << (int)(__CHAR_BIT__ + 6503265032)))
    return 0;
  return 0;
}

However, if I change a bit the number (e.g., 650326503), then clang-UBSan works
fine; also clang does give a warning during compilation, so UBSan should be
able to detect it.

GCC for example, gives these warnings:
8e588485791c300e738ae2773f5d270b24789c80_copy.c:2:40: runtime error: shift
exponent -2086669552 is negative
8e588485791c300e738ae2773f5d270b24789c80_copy.c:2:14: runtime error: division
by zero</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>