Bug 825999 - Some floating point operations return unpredictable result in different rounding modes
Some floating point operations return unpredictable result in different round...
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Jeff Law
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-05-29 06:08 EDT by Mikhail Kulemin
Modified: 2016-11-24 10:49 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-05-29 12:55:37 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Simple test code for pow() (455 bytes, text/x-csrc)
2012-05-29 06:08 EDT, Mikhail Kulemin
no flags Details

  None (edit)
Description Mikhail Kulemin 2012-05-29 06:08:42 EDT
Created attachment 587376 [details]
Simple test code for pow()

Description of problem:
Some functions from libm library (in glibc) return unpredictable result in non default rounding mode. Functions are: exp, pow etc. 

Version-Release number of selected component (if applicable): In RHEL 5.x 6.x, Fedora 16

How reproducible:

Steps to Reproduce:
1.Compile simple code 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fenv.h>


int main (int argc, char *argv[])
	int i;
	char *end;
	double x = strtod (argv[1], &end);
	if (*end != '\0')
		exit (EXIT_FAILURE);

	for (i = 0; i < 4; i++)
		double y;
		fesetround (modes[i]);
		y = pow (x,-0.34);
		printf ("pow(%.17g,-0.34) = %.17g\n", x, y);
	return 0;

with gcc: "gcc -lm -o round_mode_test round_mode_test.c"
2. Run test code with some input number
$ ./round_mode_test 2
pow(2,-0.34) = 0.79004131186337712
pow(2,-0.34) = 0.50032986487121911
pow(2,-0.34) = 0.50032986487121911
pow(2,-0.34) = 0.79004131186337723
$ ./round_mode_test 0.9
pow(0.90000000000000002,-0.34) = 1.0364719344786322
pow(0.90000000000000002,-0.34) = 1.036471934478632
pow(0.90000000000000002,-0.34) = 1.036471934478632
pow(0.90000000000000002,-0.34) = 0.0061468530371330907

Actual results:
Different result in different rounding mode

Expected results:
Same results

Additional info:
This is glibc bug http://sources.redhat.com/bugzilla/show_bug.cgi?format=multiple&id=3976 with bugfix available.
Comment 1 Mikhail Kulemin 2012-05-29 06:12:54 EDT
There are some values which cause segfault in pow() function too.
Comment 2 Jeff Law 2012-05-29 12:55:37 EDT
This was fixed when I pulled in the current glibc develoment sources into Rawhide.  I do not currently have plans to backport these changes into F17.  However, obviously, they will be in F18.

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