This is the mail archive of the glibc-cvs@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]

GNU C Library master sources branch master updated. glibc-2.26.9000-1104-g1272748


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  1272748886257ae4d73485eb7534756e89643091 (commit)
      from  b2584ac2a4d3d5ba7da01a52e6bbc495d61974c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1272748886257ae4d73485eb7534756e89643091

commit 1272748886257ae4d73485eb7534756e89643091
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Jan 10 00:02:35 2018 +0000

    Fix ldbl-128ibm lrintl, lroundl missing "invalid" exceptions (bug 22690).
    
    The ldbl-128ibm implementations of lrintl and lroundl are missing
    "invalid" exceptions for certain overflow cases when compiled with GCC
    8.  The cause of this is after-the-fact integer overflow checks that
    fail when the compiler optimizes on the basis of integer overflow
    being undefined; GCC 8 must be able to detect new cases of
    undefinedness here.
    
    Failure: lrint (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lrint_downward (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lrint_towardzero (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lrint_upward (-0x80000001p0): Exception "Invalid operation" not set
    
    Failure: lround (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lround_downward (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lround_towardzero (-0x80000001p0): Exception "Invalid operation" not set
    Failure: lround_upward (-0x80000001p0): Exception "Invalid operation" not set
    
    (Tested that these failures occur before the patch for powerpc
    soft-float, but the issue applies in principle for hard-float as well,
    whether or not the particular optimizations in fact occur there at
    present.)
    
    This patch fixes the bug by ensuring the additions / subtractions in
    question cast arguments to unsigned long int, or use 1UL as a constant
    argument, so that the arithmetic occurs in an unsigned type with the
    result then converted back to a signed type.
    
    Tested for powerpc (soft-float).
    
    	[BZ #22690]
    	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c (__lrintl): Use unsigned
    	long int for arguments of possibly overflowing addition or
    	subtraction.
    	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c (__lroundl): Likewise.

diff --git a/ChangeLog b/ChangeLog
index 6fd4c5b..679a077 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-01-10  Joseph Myers  <joseph@codesourcery.com>
+
+	[BZ #22690]
+	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c (__lrintl): Use unsigned
+	long int for arguments of possibly overflowing addition or
+	subtraction.
+	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c (__lroundl): Likewise.
+
 2018-01-09  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #22688]
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
index 62180eb..c2e2f68 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
@@ -84,7 +84,7 @@ __lrintl (long double x)
       /* Peg at max/min values, assuming that the above conversions do so.
          Strictly speaking, we can return anything for values that overflow,
          but this is more useful.  */
-      res = hi + lo;
+      res = (long int) ((unsigned long int) hi + (unsigned long int) lo);
 
       /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi).  */
       if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0)))
@@ -105,27 +105,27 @@ __lrintl (long double x)
 	    return res;
 
 	  if (xh < 0.0)
-	    res -= 1;
+	    res -= 1UL;
 	  else
-	    res += 1;
+	    res += 1UL;
 	  break;
 
 	case FE_TOWARDZERO:
 	  if (res > 0 && (xh < 0.0 || (xh == 0.0 && xl < 0.0)))
-	    res -= 1;
+	    res -= 1UL;
 	  else if (res < 0 && (xh > 0.0 || (xh == 0.0 && xl > 0.0)))
-	    res += 1;
+	    res += 1UL;
 	  return res;
 	  break;
 
 	case FE_UPWARD:
 	  if (xh > 0.0 || (xh == 0.0 && xl > 0.0))
-	    res += 1;
+	    res += 1UL;
 	  break;
 
 	case FE_DOWNWARD:
 	  if (xh < 0.0 || (xh == 0.0 && xl < 0.0))
-	    res -= 1;
+	    res -= 1UL;
 	  break;
 	}
 
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
index 9cf4a12..010e8e2 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
@@ -80,7 +80,7 @@ __lroundl (long double x)
       /* Peg at max/min values, assuming that the above conversions do so.
          Strictly speaking, we can return anything for values that overflow,
          but this is more useful.  */
-      res = hi + lo;
+      res = (long int) ((unsigned long int) hi + (unsigned long int) lo);
 
       /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi).  */
       if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0)))
@@ -92,21 +92,21 @@ __lroundl (long double x)
       hi = res;
       if (xh > 0.5)
 	{
-	  res += 1;
+	  res += 1UL;
 	}
       else if (xh == 0.5)
 	{
 	  if (xl > 0.0 || (xl == 0.0 && res >= 0))
-	    res += 1;
+	    res += 1UL;
 	}
       else if (-xh > 0.5)
 	{
-	  res -= 1;
+	  res -= 1UL;
 	}
       else if (-xh == 0.5)
 	{
 	  if (xl < 0.0 || (xl == 0.0 && res <= 0))
-	    res -= 1;
+	    res -= 1UL;
 	}
 
       if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0)))

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                               |    8 ++++++++
 sysdeps/ieee754/ldbl-128ibm/s_lrintl.c  |   14 +++++++-------
 sysdeps/ieee754/ldbl-128ibm/s_lroundl.c |   10 +++++-----
 3 files changed, 20 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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