http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57974

            Bug ID: 57974
           Summary: std::pow(std::complex<long double>(0),1) returns
                    (-nan,-nan)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: henner.sudek at gmail dot com

Created attachment 30548
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30548&action=edit
the preprocessed file (*.i*) that triggers the bug

The following program gives the wrong result when compiled with the options
given below. Removing any of the compiler options gives the expected result
(0,0). I was able to reproduce the error with gcc-4.7.3, 4.8.1 and 4.9.0.

$ cat complex.cpp
#include <complex>
#include <iostream>

int main(){
  std::cerr << std::pow(std::complex<long double>(0),1) << std::endl;
}

$ c++ -std=c++11 -fno-math-errno -funsafe-math-optimizations complex.cpp
$ ./a.out 
(-nan,-nan)

$ /home/henner/gcc-4.9.0/bin/g++ -v 
Using built-in specs.
COLLECT_GCC=/home/henner/gcc-4.9.0/bin/g++
COLLECT_LTO_WRAPPER=/home/henner/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/home/henner/gcc-4.9.0
Thread model: posix
gcc version 4.9.0 20130724 (experimental) (GCC)

Reply via email to