[LLVMbugs] [Bug 22241] New: std::complex seems to use unsafe floating point math by default

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 15 07:02:07 PST 2015


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: unassignedclangbugs at nondot.org
          Reporter: alex.hultman at strusoft.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150115/433da3c6/attachment.html>


More information about the llvm-bugs mailing list