[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Fri Apr 27 19:48:27 UTC 2018


details:   /var/hg/gmp/rev/76a1a28abbb8
changeset: 17608:76a1a28abbb8
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Fri Apr 27 21:41:59 2018 +0200
description:
Fill quotient area with junk before testing mpn_div_q.

details:   /var/hg/gmp/rev/eaf38cfcf1c4
changeset: 17609:eaf38cfcf1c4
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Fri Apr 27 21:47:59 2018 +0200
description:
Replace dead code in mpn_div_q with ASSERT.

Spotted by Paul Zimmermann and Rapha?l Rieu-Hleft.

diffstat:

 ChangeLog           |   8 ++++++++
 mpn/generic/div_q.c |  12 ++----------
 tests/mpn/t-div.c   |   1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diffs (48 lines):

diff -r 5ad5d5e6e760 -r eaf38cfcf1c4 ChangeLog
--- a/ChangeLog	Fri Apr 27 00:22:13 2018 +0200
+++ b/ChangeLog	Fri Apr 27 21:47:59 2018 +0200
@@ -1,3 +1,11 @@
+2018-04-27  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/div_q.c (mpn_div_q): Replace dead code with ASSERT.
+	Spotted by Paul Zimmermann and Raphaël Rieu-Hleft.
+
+	* tests/mpn/t-div.c (main): Fill quotient area with junk before
+	calling mpn_div_q.
+
 2018-04-26 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* Makefile.am (EXTRA_DIST): Add mini-gmp/mini-mpq.[ch].
diff -r 5ad5d5e6e760 -r eaf38cfcf1c4 mpn/generic/div_q.c
--- a/mpn/generic/div_q.c	Fri Apr 27 00:22:13 2018 +0200
+++ b/mpn/generic/div_q.c	Fri Apr 27 21:47:59 2018 +0200
@@ -170,16 +170,8 @@
 	    }
 	  if (cy == 0)
 	    qp[qn - 1] = qh;
-	  else if (UNLIKELY (qh != 0))
-	    {
-	      /* This happens only when the quotient is close to B^n and
-		 mpn_*_divappr_q returned B^n.  */
-	      mp_size_t i, n;
-	      n = new_nn - dn;
-	      for (i = 0; i < n; i++)
-		qp[i] = GMP_NUMB_MAX;
-	      qh = 0;		/* currently ignored */
-	    }
+	  else
+	    ASSERT (qh == 0);
 	}
       else  /* divisor is already normalised */
 	{
diff -r 5ad5d5e6e760 -r eaf38cfcf1c4 tests/mpn/t-div.c
--- a/tests/mpn/t-div.c	Fri Apr 27 00:22:13 2018 +0200
+++ b/tests/mpn/t-div.c	Fri Apr 27 21:47:59 2018 +0200
@@ -445,6 +445,7 @@
 	      alloc = itch + 1;
 	    }
 	  scratch[itch] = ran;
+	  MPN_COPY (qp, junkp, nn - dn + 1);
 	  mpn_div_q (qp, np, nn, dup, dn, scratch);
 	  ASSERT_ALWAYS (ran == scratch[itch]);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);


More information about the gmp-commit mailing list