This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Avoid ordered comparisons of NaNs in ldbl-128ibm acosl and asinl
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Thu, 10 Oct 2013 17:23:42 +0000
- Subject: Avoid ordered comparisons of NaNs in ldbl-128ibm acosl and asinl
- Authentication-results: sourceware.org; auth=none
ldbl-128ibm acosl and asinl receive arguments that may be NaN (the
wrappers only check for arguments with magnitude > 1.0), and do
ordered comparisons on them. The only reason this fails to raise
spurious "invalid" exceptions is, for hard-float, a GCC bug, which
I've filed as <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>.
For soft-float, it's a soft-fp bug, bug 14910, which I've proposed a
patch <https://sourceware.org/ml/libc-alpha/2013-10/msg00365.html> to
fix.
This patch adds a check for NaNs at the start of those functions to
avoid the problem (both for soft-float now, and for hard-float if the
GCC bug is fixed in future).
Tested for powerpc-nofpu.
2013-10-10 Joseph Myers <joseph@codsourcery.com>
* sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Check
for NaNs before doing comparisons on argument.
* sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl):
Likewise.
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
index 8663993..2cb2882 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
@@ -153,6 +153,8 @@ __ieee754_acosl (long double x)
{
long double a, z, r, w, p, q, s, t, f2;
+ if (__glibc_unlikely (__isnanl (x)))
+ return x + x;
a = __builtin_fabsl (x);
if (a == 1.0L)
{
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
index 99a5b85..dece118 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
@@ -134,6 +134,8 @@ __ieee754_asinl (long double x)
long double a, t, w, p, q, c, r, s;
int flag;
+ if (__glibc_unlikely (__isnanl (x)))
+ return x + x;
flag = 0;
a = __builtin_fabsl (x);
if (a == 1.0L) /* |x|>= 1 */
--
Joseph S. Myers
joseph@codesourcery.com