------- Comment #5 from tomdean at speakeasy dot org 2010-04-20 01:37 -------
Subject: Re: Tanh Returns Incorrect Value
On Mon, 2010-04-19 at 23:57 +0000, pinskia at gcc dot gnu dot org wrote:
>
> ------- Comment #4 from pinskia at gcc dot gnu dot org 2010-04-19 23:57
> -------
> And tanhl is a GCC issue how? It is part of glibc and not GCC so please
> report
> it to them.
> Plus it works for me with:
> libc version 2.7
> libc release stable
>
> On Debian 5.0.
Sorry, I crossed wires when replying to your previous email. I have two
problems, one with libc and the other with libstdc++.
and, in gcc-4.4.1/libstdc++-v3/include/std/complex
template<typename _Tp>
inline complex<_Tp>
__complex_tanh(const complex<_Tp>& __z)
{ return std::sinh(__z) / std::cosh(__z); }
...
template<typename _Tp>
inline complex<_Tp>
__complex_sinh(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
}
...
template<typename _Tp>
inline complex<_Tp>
__complex_cosh(const complex<_Tp>& __z)
{
const _Tp __x = __z.real();
const _Tp __y = __z.imag();
return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
}
And, these all seem to resolve to gcc builtin's, like
__builtin_coshl(__x);, etc.
Is this true?
The code below was compiled with: g++ test-tanh.cc -o test-tanh-cc
>test-tanh-cc
arg (50000,50000)
sinh(arg) (-inf,-inf)
cosh(arg) (-inf,-inf)
s/c (nan,nan)
tanh(arg) (nan,0)
>./test-tanh-cc 5678
arg (5678,5678)
sinh(arg) (-1.74513e+2465,-3.81804e+2465)
cosh(arg) (-1.74513e+2465,-3.81804e+2465)
s/c (1,-0)
tanh(arg) (1,2.14543e-4932)
>./text-tanh-cc 5679
arg (5679,5679)
sinh(arg) (6.17015e+2465,-9.59925e+2465)
cosh(arg) (6.17015e+2465,-9.59925e+2465)
s/c (1,-0)
tanh(arg) (nan,-0)
> cat test-tanh.cc
#include <iostream>
#include <complex>
#include <gnu/libc-version.h>
#include <stdlib.h> // atol
using namespace std;
int main(int argc, char **argv) {
long mult;
if (argc == 2) {
mult = atol(argv[1]);
} else {
mult = 50000L;
}
complex<long double> arg(1,1);
arg *= mult;
complex<long double> s,c,r,t;
s=sinh(arg);
c=cosh(arg);
r=s/c;
t=tanh(arg);
cout << "libc version " << gnu_get_libc_version() << endl;
cout << "arg " << arg << endl;
cout << "sinh(arg) " << s << endl;
cout << "cosh(arg) " << c << endl;
cout << "s/c " << r << endl;
cout << "tanh(arg) " << t << endl;
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802