[Bug libstdc++/61849] New: exp(NaN+0_i) returns wrong value

bolero.murakami at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jul 19 04:12:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61849

            Bug ID: 61849
           Summary: exp(NaN+0_i) returns wrong value
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bolero.murakami at gmail dot com

exp(NaN+0_i) returns NaN+NaN_i.
However, it should returns NaN+0_i correctly.

ISO/IEC 9899:1999
G.6.3.1 The cexp functions
— cexp(NaN + i0) returns NaN + i0.

Code:
//--------
#include <complex>
#include <limits>
#include <iostream>

int main() {
    using complex = std::complex<double>;
    auto NaN = std::numeric_limits<double>::quiet_NaN();

    // should be (nan,0), but (nan,nan)
    std::cout << std::exp(complex(NaN, +0.)) << std::endl;
    // should be (nan,-0), but (nan,nan)
    std::cout << std::exp(complex(NaN, -0.)) << std::endl;
}
//--------
http://melpon.org/wandbox/permlink/asWdib1m9tY4zICI


More information about the Gcc-bugs mailing list