Bug 97159 - broken floating pointer arithmetic
broken floating pointer arithmetic
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
9
i386 Linux
high Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-06-10 21:32 EDT by Dmitry V. Levin
Modified: 2007-03-27 00:06 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-06-17 13:09:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Dmitry V. Levin 2003-06-10 21:32:28 EDT
Description of problem: 
gcc-3.2.2-5 improperly compiles ynf(3) - float version of Bessel function. 
 
Version-Release number of selected component (if applicable): 
gcc-3.2.1-7 and earler versions are ok; 
gcc-3.2.2-5 is not ok; 
gcc-3.3-4 is ok again; 
looks like something is broken in gcc-3_2-rhl8-branch. 
 
How reproducible: 
always 
 
Steps to Reproduce: 
Just test result of ynf(3,0.1) with glibc compiled by different gcc versions, for 
example using this trivial program: 
 
/* gcc -pipe -Wall -g -O2 -march=i386 ynf.c -lm -o ynf */ 
#include <stdio.h> 
#include <math.h> 
int main(void) 
{ 
	int n = 3; 
	float xf = 0.1; 
	double xd = 0.1; 
	printf ("ynf(%d,%f) = %1.12e\n", n, xf, ynf(n, xf)); 
	printf ("yn (%d,%f) = %1.12e\n", n, xd, yn(n, xd)); 
	printf ("ynf - yn        = %1.12e\n", (double)ynf(n, xf) - yn(n, xd)); 
	return 0; 
} 
 
You'll see following results: 
 
Rawhide: glibc-2.3.2-48 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.3 20030602 (Red Hat Linux 3.3-4). 
Compiled on a Linux 2.4.20 system on 2003-06-05. 
$ ./ynf 
ynf(3,0.100000) = -5.099332031250e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 3.473629039945e-04 
 
RH9+updates: glibc-2.3.2-27.9 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.2.2 20030222 (Red Hat Linux 3.2.2-5). 
Compiled on a Linux 2.4.20 system on 2003-04-07. 
$ ./ynf 
ynf(3,0.100000) = -5.099332031250e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 8.356441549040e-04 
 
RH9: glibc-2.3.2-11.9 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.2.2 20030222 (Red Hat Linux 3.2.2-5). 
Compiled on a Linux 2.4.20 system on 2003-03-13. 
$ ./ynf 
ynf(3,0.100000) = -5.099331542969e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 8.356441549040e-04 
 
Beta(phoebe): glibc-2.3.1-46 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.2.1 20030202 (Red Hat Linux 8.0 3.2.1-7). 
Compiled on a Linux 2.4.20 system on 2003-02-14. 
$ ./ynf 
ynf(3,0.100000) = -5.099332031250e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 3.473629039945e-04 
 
RH8.0+updates: glibc-2.3.2-4.80.6 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.2 20020903 (Red Hat Linux 8.0 3.2-7). 
Compiled on a Linux 2.4.9-9 system on 2003-04-07. 
$ ./ynf 
ynf(3,0.100000) = -5.099332031250e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 3.473629039945e-04 
 
RH8.0: glibc-2.2.93-5 
$ /lib/libc.so.6 |grep ^Compiled 
Compiled by GNU CC version 3.2 20020903 (Red Hat Linux 8.0 3.2-7). 
Compiled on a Linux 2.4.9-9 system on 2002-09-05. 
$ ./ynf 
ynf(3,0.100000) = -5.099332031250e+03 
yn (3,0.100000) = -5.099332378613e+03 
ynf - yn        = 3.473629039945e-04 
 
Additional info: 
Vanilla gcc-3.2.3 compiles ynf(3) properly, tested on glibc-2.3.2-27.9.
Comment 1 Dmitry V. Levin 2003-06-11 05:24:16 EDT
gcc-3.2.3-4 also miscompiles ynf(3). 
 
Comment 2 Jakub Jelinek 2003-06-17 13:09:49 EDT
I hope you realize you're talking here about single ulp difference, ie.
ynf error in gcc-3.3 compiled libm is ~0.68ulp and in gcc-3.2 compiled libm
is ~1.68ulp. You can certainly find inputs where gcc-3.2 compiled libm
will give you better results than gcc-3.3 compiled one.
<= 0.5ulps errors are expected for double functions only, and even there I'm
not sure it works 100%. Please look at libm-test-ulps for various arches to 
see what you can approximately expect.
Certainly, if you want to rewrite ynf so that it will guarantee <= 0.5ulps,
patches are welcome.

Note You need to log in before you can comment on or make changes to this bug.