<html>
<head>
<base href="http://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 --- - -fsanitize=undefined false positive on conditional operator and floating-point division by 0 with constants"
href="http://llvm.org/bugs/show_bug.cgi?id=17381">17381</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-fsanitize=undefined false positive on conditional operator and floating-point division by 0 with constants
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vincent-llvm@vinc17.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>ypig:~> clang --version
Debian clang version 3.4-1 (trunk) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
ypig:~> cat tst.c
#include <stdio.h>
int main (void)
{
volatile int i, t = 0;
volatile double x;
double z = 0.0;
i = t ? 0 / 0 : 0;
printf ("[1] %d\n", i);
x = t ? z / z : z;
printf ("[2] %g\n", x);
x = t ? 0.0 / 0.0 : 0.0;
printf ("[3] %g\n", x);
return 0;
}
ypig:~> clang -fsanitize=undefined tst.c -o tst
tst.c:9:13: warning: division by zero is undefined [-Wdivision-by-zero]
i = t ? 0 / 0 : 0;
^ ~
1 warning generated.
ypig:~> ./tst
[1] 0
[2] 0
tst.c:13:15: runtime error: division by zero
[3] 0
but because t == 0, the 0.0 / 0.0 in the third test should never be evaluated.
The first two tests are OK, so that it seems related to floating-point division
with constants specifically.
This bug yields a failure in the tget_flt test of the GNU MPFR trunk r8685
with:
clang -O2 -fsanitize=undefined -fno-sanitize-recover</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>