| Anonymous | Login | Signup for a new account | 2013-06-20 12:37 UTC | ![]() |
| Main | My View | View Issues | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0003326 | CentOS-5 | gcc | public | 2009-01-05 18:41 | 2009-01-06 16:02 | ||||||
| Reporter | griznog | ||||||||||
| Priority | normal | Severity | major | Reproducibility | always | ||||||
| Status | new | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 5.2 | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0003326: rint() returns incorrect values on x86_64 | ||||||||||
| Description | rint() on x86_64 returns incorrect results for some numbers with even major parts. This program demonstrates the error: /* rint.c */ #include <stdio.h> #include <math.h> int main(int argc, char **argv) { double a, b; double rint(double x); a = 289440.59; b = rint(a); printf("%15.12f %15.12f\n", a, b); a = 289440.75; b = rint(a); printf("%15.12f %15.12f\n", a, b); a = 289441.59; b = rint(a); printf("%15.12f %15.12f\n", a, b); a = 289441.75; b = rint(a); printf("%15.12f %15.12f\n", a, b); a = 289442.59; b = rint(a); printf("%15.12f %15.12f\n", a, b); a = 289442.75; b = rint(a); printf("%15.12f %15.12f\n", a, b); } Building/running 64 bit version: [griznog@ictalurus ~]$ gcc -o rint -lm rint.c && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 Building/running 32 bit version: [griznog@ictalurus ~]$ gcc -o rint -lm -m32 rint.c && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 Test system: [griznog@ictalurus ~]$ uname -a Linux ictalurus 2.6.18-92.1.22.el5 0000001 SMP Tue Dec 16 11:57:43 EST 2008 x86_64 x86_64 x86_64 GNU/Linux [griznog@ictalurus ~]$ rpm -qa | grep glibc compat-glibc-headers-2.3.4-2.26 glibc-devel-2.5-24.el5_2.2 compat-glibc-2.3.4-2.26 glibc-2.5-24.el5_2.2 compat-glibc-2.3.4-2.26 glibc-common-2.5-24.el5_2.2 glibc-devel-2.5-24.el5_2.2 glibc-headers-2.5-24.el5_2.2 glibc-2.5-24.el5_2.2 | ||||||||||
| Additional Information | This bug does not occur with gcc on FreeBSD (amd64) or Mac OS X 10.5. I've tested on intel and amd and it doesn't seem to be CPU related. I'm at a loss for who to report this too or how to go about debugging it further. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0008532) griznog (reporter) 2009-01-05 18:44 |
This link has a better description and suggested fix: http://sourceware.org/bugzilla/show_bug.cgi?id=5857 [^] |
|
(0008534) tru (administrator) 2009-01-05 20:34 edited on: 2009-01-05 20:41 |
[tru@woodstock ~]$ gcc -Wall -O3 -o rint -lm rint.c && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 [tru@woodstock ~]$ gcc -Wall -O0 -o rint -lm rint.c && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 reproduced and there is a compiler optimisation side effect [tru@woodstock ~]$ rpm -q glibc gcc binutils glibc-devel glibc-2.5-24.el5_2.2.x86_64 glibc-2.5-24.el5_2.2.i686 gcc-4.1.2-42.el5.x86_64 binutils-2.17.50.0.6-6.el5.x86_64 glibc-devel-2.5-24.el5_2.2.x86_64 glibc-devel-2.5-24.el5_2.2.i386 [tru@wyatt ~]$ rpm -q glibc gcc binutils glibc-devel glibc-2.5-24.el5_2.2.i686 glibc-2.5-24.el5_2.2.x86_64 gcc-4.1.2-42.el5.x86_64 binutils-2.17.50.0.6-6.el5.x86_64 glibc-devel-2.5-24.el5_2.2.x86_64 glibc-devel-2.5-24.el5_2.2.i386 [tru@wyatt ~]$ icc -O3 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 [tru@wyatt ~]$ icc -O0 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 [tru@wyatt ~]$ gcc -O0 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 [tru@wyatt ~]$ icc -V Intel(R) C Compiler for applications running on Intel(R) 64, Version 10.1 Build 20080801 Package ID: l_cc_p_10.1.018 Copyright (C) 1985-2008 Intel Corporation. All rights reserved. |
|
(0008535) tru (administrator) 2009-01-05 20:59 edited on: 2009-01-05 21:04 |
same issue on gcc on CentOS-3 x86_64 (even with gcc 4.2.0) [tru@sillage ~]$ rpm -q gcc glibc-devel binutils glibc gcc-3.2.3-59.x86_64 glibc-devel-2.3.2-95.50.i386 glibc-devel-2.3.2-95.50.x86_64 binutils-2.14.90.0.4-42.x86_64 glibc-2.3.2-95.50.i686 glibc-2.3.2-95.50.x86_64 [tru@sillage ~]$ gcc -O3 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 [tru@sillage ~]$ gcc -O0 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 with a self compiled gcc 4.2.0: [tru@sillage ~]$ gcc -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/opt/gnu/gcc42 Thread model: posix gcc version 4.2.1 [tru@sillage ~]$ gcc -O3 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 [tru@sillage ~]$ gcc -O0 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 [tru@sillage ~]$ gcc -m32 -O0 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 [tru@sillage ~]$ gcc -m32 -O3 rint.c -o rint -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289441.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289443.000000000000 |
|
(0008536) tru (administrator) 2009-01-05 21:28 |
nice one: same issue on c4 x86_64 [tru@karshan ~]$ gcc -O0 -o rint rint.c -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 [tru@karshan ~]$ gcc -O3 -o rint rint.c -lm && ./rint 289440.590000000026 289441.000000000000 289440.750000000000 289440.000000000000 289441.590000000026 289442.000000000000 289441.750000000000 289442.000000000000 289442.590000000026 289443.000000000000 289442.750000000000 289442.000000000000 [tru@karshan ~]$ rpm -q binutils glibc glibc-devel gcc binutils-2.15.92.0.2-25.x86_64 glibc-2.3.4-2.41.x86_64 glibc-2.3.4-2.41.i686 glibc-devel-2.3.4-2.41.x86_64 gcc-3.4.6-10.x86_64 |
|
(0008543) tru (administrator) 2009-01-06 16:02 |
https://bugzilla.redhat.com/show_bug.cgi?id=479025 [^] |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2009-01-05 18:41 | griznog | New Issue | |
| 2009-01-05 18:44 | griznog | Note Added: 0008532 | |
| 2009-01-05 20:34 | tru | Note Added: 0008534 | |
| 2009-01-05 20:41 | tru | Note Edited: 0008534 | |
| 2009-01-05 20:59 | tru | Note Added: 0008535 | |
| 2009-01-05 21:04 | tru | Note Edited: 0008535 | |
| 2009-01-05 21:28 | tru | Note Added: 0008536 | |
| 2009-01-06 16:02 | tru | Note Added: 0008543 | |
| Copyright © 2000 - 2011 MantisBT Group |