<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 - Inconsistent UndefinedSanitizer report"
   href="https://bugs.llvm.org/show_bug.cgi?id=52421">52421</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inconsistent UndefinedSanitizer report
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>13.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>shaohua.li@inf.ethz.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi there,

I found that the UndefinedSanitizer would report runtime error on the follow
code:

$cat a.c
int main() {
    double x = 2147483649;
    int y = x;
}
$
$clang-13 -fsanitize=undefined a.c ; ./a.out
a.c:3:10: runtime error: 2.14748e+09 is outside the range of representable
values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior a.c:3:10


However, if I changed the 'double' type to 'long', the error report went away.
$cat a.c
int main() {
    long x = 2147483649;
    int y = x;
}
$
$clang-13 -fsanitize=undefined a.c ; ./a.out
$</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>