about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128ibm/e_powl.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-12-02 23:21:15 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-12-02 23:21:15 +0000
commit90ab295a9e07fe4f6caaa9c19e03b3fba3f3e10d (patch)
treed2e4fe7ece5d12b6b011d1336c5afe2fca7c4a0e /sysdeps/ieee754/ldbl-128ibm/e_powl.c
parent72d839a42f4c4ed2e0a5202a0d9829c3debae20f (diff)
downloadglibc-90ab295a9e07fe4f6caaa9c19e03b3fba3f3e10d.tar.gz
glibc-90ab295a9e07fe4f6caaa9c19e03b3fba3f3e10d.tar.xz
glibc-90ab295a9e07fe4f6caaa9c19e03b3fba3f3e10d.zip
Fix sysdeps/ieee754 pow handling of sNaN arguments (bug 20916).
Various pow function implementations mishandle sNaN arguments in
various ways.  This includes returning sNaN instead of qNaN for sNaN
arguments.  For arguments (1, sNaN) and (sNaN, 0), TS 18661-1
semantics are also that the result should be qNaN, whereas with a qNaN
argument there the result should be 1, but for the dbl-64
implementation of pow there are issues with sNaN arguments beyond not
implementing the TS 18661-1 semantics in those special cases.

This patch makes the implementations in sysdeps/ieee754 follow the TS
18661-1 semantics consistently.  Because x86 / x86_64 implementations
still need fixing, testcases are not included with this patch; they
will be included with the fix for the x86 / x86_64 versions.

Tested for x86_64, x86, mips64 and powerpc (with such testcases, which
pass in the mips64 and powerpc cases).

	[BZ #20916]
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Do not return 1
	for arguments (sNaN, 0) or (1, sNaN).  Do arithmetic on NaN
	arguments to compute result.
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Do not return
	1 for arguments (sNaN, 0) or (1, sNaN).
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise.
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/e_powl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_powl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_powl.c b/sysdeps/ieee754/ldbl-128ibm/e_powl.c
index 861b44ac8b..d6fbef6997 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_powl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_powl.c
@@ -165,11 +165,11 @@ __ieee754_powl (long double x, long double y)
   iy = hy & 0x7fffffff;
 
   /* y==zero: x**0 = 1 */
-  if ((iy | ly) == 0)
+  if ((iy | ly) == 0 && !issignaling (x))
     return one;
 
   /* 1.0**y = 1; -1.0**+-Inf = 1 */
-  if (x == one)
+  if (x == one && !issignaling (y))
     return one;
   if (x == -1.0L && ((iy - 0x7ff00000) | ly) == 0)
     return one;