This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ldbl-128ibm nexttowar[d/f/l] generates spurious inexact exception


This is triggered by glibc testcase "nexttowar[d/f/l] (qNaN, 1.1)". The source
of the issue is sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c,
sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c, and sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
all return 'x+y' as return if x or y is a NaN.

This fix is to return __builtin_nan[f|l]  instead. Ok to commit?

---

2013-05-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Fix spurious
	inexact exception for NaN inputs.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf): Likewise.

--

diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
index ff5d7d3..0c9324b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
@@ -44,7 +44,7 @@ long double __nextafterl(long double x, long double y)
 	    ((ihx&0x000fffffffffffffLL)!=0)) ||   /* x is nan */
 	   (((ihy&0x7ff0000000000000LL)==0x7ff0000000000000LL)&&
 	    ((ihy&0x000fffffffffffffLL)!=0)))     /* y is nan */
-	    return x+y; /* signal the nan */
+	    return __builtin_nanl ("");
 	if(x==y)
 	    return y;		/* x=y, return y */
 	if(ihx == 0 && ilx == 0) {			/* x == 0 */
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
index 40f0c46..38d2a37 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
@@ -46,7 +46,7 @@ double __nexttoward(double x, long double y)
 	if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||   /* x is nan */
 	   ((iy>=0x7ff0000000000000LL)&&((iy-0x7ff0000000000000LL)|uly)!=0))
 	   						    /* y is nan */
-	   return x+y;
+	   return __builtin_nan ("");
 	if((long double) x==y) return y;	/* x=y, return y */
 	if((ix|lx)==0) {			/* x == 0 */
 	    double u;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
index b387a91..617c5b6 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
@@ -38,7 +38,7 @@ float __nexttowardf(float x, long double y)
 	if((ix>0x7f800000) ||   /* x is nan */
 	   ((iy>=0x7ff0000000000000LL)&&((iy-0x7ff0000000000000LL)|uly)!=0))
 				/* y is nan */
-	   return x+y;
+	   return __builtin_nanf ("");
 	if((long double) x==y) return y;	/* x=y, return y */
 	if(ix==0) {				/* x == 0 */
 	    float u;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]