<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 --- - std::complex seems to use unsafe floating point math by default"
   href="http://llvm.org/bugs/show_bug.cgi?id=22241">22241</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::complex seems to use unsafe floating point math by default
          </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++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alex.hultman@strusoft.com
          </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>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</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>