Bug#328504: libc6: Wrong computation of tanh
Package: libc6
Version: 2.3.2.ds1-22
Severity: wishlist
For the full context in which this bug report originated, please see:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=327027
Before I summarize the discussion in the URL above, let me say that I am not
fully sure that filing this bug report is appropriate (hence severity:
wishlist). Feel free to close this bug report, in particular if a new
version of glibc which fixes the bug (see below) is coming soon.
Here is the scoop:
The octave package fails a regression test when compiled with g++ 4.0.
This regression test uses the tanh (hyperbolic tangent) function. When
octave is compiled compiled with g++ 3.3, everything goes well. We
investigated this problem further and discovered that g++ now uses the
glibc tanh function instead of using "sinh(x)/cosh(x)" as before.
The following simple program triggers the bug (thanks to John W. Eaton):
#include <cmath>
#include <iostream>
#include <complex>
int
main (void)
{
std::cout << std::tanh (std::complex<double> (0, M_PI/2)) << std::endl;
std::cout << std::tanh (std::complex<double> (0, 3*M_PI/2)) << std::endl;
return 0;
}
This should produce (0, inf) in both cases. With g++ 3.3, it is
still not right, as it produces
(0,1.63318e+16)
(0,5.44393e+15)
With g++ 4.0:
(nan, inf)
(nan, inf)
This bug has been reported upstream:
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=160759
and fixed on 2005-07-10. Indeed, the libc/ChangeLog at:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/ChangeLog?rev=1.9521&content-type=text/x-cvsweb-markup&cvsroot=glibc
has the following entry:
2005-07-07 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/s_ctanh.c (__ctanh): Handle case of zero den better.
* sysdeps/generic/s_ctanhf.c (__ctanhf): Likewise.
* sysdeps/generic/s_ctanhl.c (__ctanhl): Likewise.
* sysdeps/generic/s_ctan.c (__ctan): Likewise.
* sysdeps/generic/s_ctanf.c (__ctanf): Likewise.
* sysdeps/generic/s_ctanl.c (__ctanl): Likewise.
Could the patch shown in
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/generic/s_ctanh.c.diff?r1=1.2&r2=1.3&cvsroot=glibc&f=h
be applied to the Debian package?
Thanks,
--
Rafael
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.8-1-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Versions of packages libc6 depends on:
ii libdb1-compat 2.1.3-7 The Berkeley database routines [gl
libc6 recommends no packages.
-- no debconf information
Reply to: