<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 - UBSan is inconsistent about erroring on dead code in ternary operator branches"
   href="https://bugs.llvm.org/show_bug.cgi?id=52270">52270</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSan is inconsistent about erroring on dead code in ternary operator branches
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>regehr@cs.utah.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://gcc.godbolt.org/z/WxKjWMo47">https://gcc.godbolt.org/z/WxKjWMo47</a>

in this example program (supplied by Pascal Cuoq), UBSan should either error in
both cases, or in neither of them (I would argue that it should not error in
either case, but ymmv):

void f(int a) {
  a ? 0 : 0x7fffffff + 1;
}

void g(int a) {
  a ? 0 : 0 >> 32;
}

int main(void) {
    f(1);
    g(1);
}

instead, however, UBSan errors on the shift bug, but not on the overflowing
addition. when this program is run, this is the output we see:

/app/example.c:6:13: runtime error: shift exponent 32 is too large for 32-bit
type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /app/example.c:6:13 in</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>