<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - UBSAN fails to catch shifts by more than 1<<32"
   href="https://llvm.org/bugs/show_bug.cgi?id=27271">27271</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSAN fails to catch shifts by more than 1<<32
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>cherepan@mccme.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>UBSAN doesn't warn about this program:

int main(int c, char **v) { 1 << ((long)c << 32); }

Run as `clang -Wno-unused-value -fsanitize=undefined example.c && ./a.out`.
Tested with clang version 3.9.0 (trunk 265708) on x86-64.

gcc6 warns:
example.c:1:31: runtime error: shift exponent 4294967296 is too large for
32-bit type 'int'

Looking at IR, it seems the right operand of the shift is checked only after
it's truncated to 32-bit. This is too late.</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>