<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 --- - NAN generated by legitimate long double code"
href="http://llvm.org/bugs/show_bug.cgi?id=22105">22105</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>NAN generated by legitimate long double code
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>carlo.milanesi@tiscali.it
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The command line:
clang++ -O -I../ bug.cpp -obug.exe && ./bug.exe && echo FAIL
prints:
FAIL
when the `bug.cpp` file has the following contents:
#include <cmath>
int main(int, char**)
{
typedef long double const type;
type d = std::sqrt(26.L);
type u = 1 * d;
type v = -5 * d;
type w = 0 * d;
type angle = 0.6;
type cos_a = 0.8;
type sin_a = std::sin(angle);
type xx = 3 * (u * u) - (7 * v + 5 * w) + 7 * sin_a;
type yy = (7 - 3 * u * v) * cos_a + 5 * sin_a;
type zz = (5 * (1 - w * w) - u * w) * cos_a + 3 * v * sin_a;
return xx + yy + zz < 0 || xx + yy + zz > 0;
}
Removing `const` has no apparent effect.
If at the beginning it is inserted the line:
#include <iostream>
and the `return` statement is replaced by the line:
std::cout << xx << yy << zz << std::endl;
the output is:
-nan-nan-nan
FAIL
If the command line is:
g++-4.7 -O bug.cpp -obug.exe && ./bug.exe && echo FAIL
or
clang++ bug.cpp -obug.exe && ./bug.exe && echo FAIL
The first program has no output, and the second one prints:
260.418320.423-39.1868
FAIL
(Although it prints FAIL, it is correct).
The command:
clang --version
prints:
Ubuntu clang version 3.4-1ubuntu3~precise2 (tags/RELEASE_34/final)
(based on LLVM 3.4)
Target: i386-pc-linux-gnu
Thread model: posix
The original defect was in a much more complex code, that I simplified.
At any simplification I try to the above code, the defect disappears.
It appears to be a defect in the optimization of `long double` computations.</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>