[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
data.cc failing 1 test
From: |
John W. Eaton |
Subject: |
data.cc failing 1 test |
Date: |
Thu, 17 Dec 2009 02:26:30 -0500 |
On 16-Dec-2009, Rik wrote:
| 'make check' is failing for one test in data.cc. I'm pretty sure I was
| able to pass the entire test suite as little as two weeks ago.
|
| >>>>> processing octave-dev/src/data.cc
| ***** assert(log2(complex(0,Inf)), Inf + log2(i));
| !!!!! test failed
| assert (log2 (complex (0, Inf)),Inf + log2 (i)) expected
| Inf + 2.266i
| but got
| Inf - NaNi
| NaNs don't match
What compiler are you using? What options? For the following
program, I see the following result with g++ -O0,
$ g++ -O0 cmplx-bug.cc
$ ./a.out
inf, (0,inf)
(inf,nan)
but with -O2, I see
$ g++ -O2 cmplx-bug.cc
$ ./a.out
inf, (0,inf)
(inf,2.26618)
So I think this is a bug in g++ or the complex class in the GNU
libstdc++ library.
I'm using
$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.4-6'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.4 (Debian 4.3.4-6)
but I also see the same result with g++ 3.3, 4.0, 4.1, and 4.2.
jwe
#include <iostream>
#include <complex>
std::complex<double>
xlog2 (const std::complex<double>& x)
{
#if defined (M_LN2)
static double ln2 = M_LN2;
#else
static double ln2 = log (2);
#endif
return std::log (x) / ln2;
}
int
main (void)
{
double inf = 1.0 / 0.0;
std::complex<double> infi (0.0, inf);
std::cerr << inf << ", " << infi << std::endl;
std::cerr << xlog2 (infi) << std::endl;
return 0;
}