Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 20492 - cosh function in <cmath> giving wrong results
Summary: cosh function in <cmath> giving wrong results
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-05 12:55 UTC by Alessandro Flacco
Modified: 2004-10-15 23:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Flacco 2003-05-05 12:55:34 UTC
while working on some kind of math simulation program I found many strange
results; the function I found having strange behaving is cosh (hyperbolic cosine)
Note that this results are consistent with the ones from any calctool compiled
on the same machine (es Calcoo).
This problem doesn't seems to affect gentoo systems NOT compiled for pentium4

Simply, the output of
int main()
{
        int i;
        double start_point=4.18524;
        for (i=0;i<10;i++)
cout<<((double)i)*0.00001+start_point<<"\t"<<cosh(((double)i)*0.00001+start_point)<<endl;
        return(0);
}

isn't the right one

// compile with c++ -o cosh_test 


Reproducible: Always
Steps to Reproduce:
1.compile and run the program
2.compare the results with any gentoo not compiled with march=pentium4


Actual Results:  
output:

4.18524 65.7093
4.18525 65.7099
4.18526 inf
4.18527 inf
4.18528 65.7119
4.18529 65.7126
4.1853  inf
4.18531 inf
4.18532 65.7145
4.18533 65.7152


Expected Results:  
4.18524 32.8622
4.18525 32.8626
4.18526 32.8629
4.18527 32.8632
4.18528 32.8636
4.18529 32.8639
4.1853  32.8642
4.18531 32.8645
4.18532 32.8649
4.18533 32.8652


Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r4)
=================================================================
System uname: 2.5.64 i686 Intel(R) Pentium(R) 4 CPU 2.00GHz
GENTOO_MIRRORS=" ftp://ftp.tu-clausthal.de/pub/linux/gentoo/
ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo
http://212.219.56.162/sites/www.ibiblio.org/gentoo/"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config
/usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/kde/3.1/share/config
/usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY=""
USE="x86 oss 3dnow apm arts avi crypt cups encode gif jpeg libg++ mikmod mpeg
ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib gdbm berkdb
slang readline svga java guile sdl gpm tcpd pam libwww ssl perl python esd imlib
oggvorbis qt motif opengl mozilla cdr X gtk gnome -alsa sse mmx -kde"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O3 -pipe"
CXXFLAGS="-march=pentium4 -O3 -pipe"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j1"
AUTOCLEAN="no"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
FEATURES="sandbox ccache"
Comment 1 Alex Veber 2003-05-07 11:59:17 UTC
The warning in make.conf about not using -march=pentium4 is there for a reason :/  
Comment 2 Alessandro Flacco 2003-05-07 13:04:34 UTC
I knew I shouldn't have used -march=pentium4 but I needed, for a simulation, the fastest results I can, so I tried (thinking that the "illegal instructions" wouldn't have affected math functions in glibc...).

Anyway, recompiling glibc with -march=pentium3 will solve the problem
Comment 3 SpanKY gentoo-dev 2004-10-15 23:28:19 UTC
old issue, newer toolchain solves these problems