This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/763] New: On AMD64 in IEEE round-to-plus-infinity (upward) mode, pow() may segfault and exp() yield negative results
- From: "David dot Monniaux at ens dot fr" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 24 Feb 2005 17:19:12 -0000
- Subject: [Bug libc/763] New: On AMD64 in IEEE round-to-plus-infinity (upward) mode, pow() may segfault and exp() yield negative results
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
On AMD64, after a fesetround(FE_UPWARD), on certain values:
- pow() issues a segmentation fault
- exp() yields a negative result
#include <math.h>
#include <fenv.h>
#include <stdio.h>
int main()
{
double x = 79.252413924118542354335659183561801910400390625;
double y = 0.333333299999999999041477849459624849259853363037109375;
double z;
fesetround(FE_UPWARD);
z = pow(x,y); /* segfault my_log2 () */
return 0;
}
#include <math.h>
#include <fenv.h>
#include <stdio.h>
int main()
{
double x = 79.252413924118542354335659183561801910400390625;
double y = 0.333333299999999999041477849459624849259853363037109375;
double z;
double a = 10e18;
double b = 1.0;
fesetround(FE_UPWARD);
z = exp(log(x)*y);
printf("%lf %lf\n", (a+b)-a, z); /* second number output is -0.246008 */
return 0;
}
I note that ./sysdeps/ieee754/dbl-64/e_pow.c states
"Assumption: Machine arithmetic operations are performed in round to nearest
mode of IEEE 754 standard."
Proposed fix: if glibc does not attempt to provide the nearest upward or
downward result for pow() and exp() in non-nearest rounding modes, one can use
the exp2() and log2() primitives.
ex: pow(x, y) = exp2(log2(x) * y)
--
Summary: On AMD64 in IEEE round-to-plus-infinity (upward) mode,
pow() may segfault and exp() yield negative results
Product: glibc
Version: 2.3.3
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: David dot Monniaux at ens dot fr
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://sources.redhat.com/bugzilla/show_bug.cgi?id=763
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.