<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 - NaN compares equal for SPARC V9"
href="https://bugs.llvm.org/show_bug.cgi?id=42496">42496</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>NaN compares equal for SPARC V9
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Sun
</td>
</tr>
<tr>
<th>OS</th>
<td>Solaris
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>miscompilation
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: Sparc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ro@gcc.gnu.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, venkatra@cs.wisc.edu
</td>
</tr></table>
<p>
<div>
<pre>When investigating the last test failures on SPARC (for
<a href="https://reviews.llvm.org/D40900">https://reviews.llvm.org/D40900</a>),
I found two failures that boil down to long double NaN comparing equal to
itself
on 64-bit SPARC:
Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
Builtins-sparcv9-sunos :: divtc3_test.c
They seem to boil down to the following testcase:
$ cat nancmp.c
#include <math.h>
#include <stdio.h>
int
main (void)
{
long double lnan = NAN;
long double mlnan = -NAN;
if (lnan != lnan)
printf ("nan neq\n");
else
printf ("nan eq\n");
if (mlnan != mlnan)
printf ("-nan neq\n");
else
printf ("-nan eq\n");
return 0;
}
$ gcc -m32 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
gcc -m64 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
$ clang -m32 -o nancmp nancmp.c && ./nancmp
nan neq
-nan neq
$ clang -m64 -o nancmp nancmp.c && ./nancmp
nan eq
-nan eq
This may be due to the fact that clang calls _Qp_cmp for the comparison, which
returns unordered (3) in this case, while gcc uses _Qp_feq, which just returns
unequal (0) instead.</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>