http://llvm.org/bugs/show_bug.cgi?id=22241
Bug ID: 22241
Summary: std::complex seems to use unsafe floating point math
by default
Product: clang
Version: 3.4
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Hi.
Consider the following code:
#include <complex>
#include <iostream>
#include <iomanip>
int main()
{
std::complex<double> c(-61.887073591767951,-60.052083270252012);
double a = (1.0 / c).real();
std::cout << std::setprecision(17) << " " << a << std::endl;
}
With g++ and gfortran (with corresponding Fortran code) and Octave (ditto),
this outputs:
-8.3223357032193145 (ends with 45)
However, clang++ outputs:
-0.0083223357032193128 (ends with 28)
The thing is, when compiling with g++ -ffast-math, I get the same as I get in
clang++ (without any optimization or -ffast-math).
So: "g++ -ffast-math complex.cpp" gives the same output as "clang++
complex.cpp"
I'm on Fedora 21 with clang++ --version:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs