[Gmp-commit] /home/hgfiles/gmp: Fix ASSERTs.

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 23 18:41:53 CET 2009


details:   /home/hgfiles/gmp/rev/98f18622767c
changeset: 13205:98f18622767c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Dec 23 18:41:05 2009 +0100
description:
Fix ASSERTs.

diffstat:

 ChangeLog                      |  2 ++
 mpn/generic/toom_eval_pm2exp.c |  8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 61fe62428855 -r 98f18622767c ChangeLog
--- a/ChangeLog	Wed Dec 23 17:31:50 2009 +0100
+++ b/ChangeLog	Wed Dec 23 18:41:05 2009 +0100
@@ -1,5 +1,7 @@
 2009-12-23  Marco Bodrato <bodrato at mail.dm.unipi.it>
 
+	* mpn/generic/toom_eval_pm2exp.c: Fix ASSERTs.
+
 	* mpn/generic/toom8h_mul.c: New file.
 	* mpn/generic/toom8_sqr.c: New file.
 	* mpn/generic/toom_interpolate_16pts.c: New file.
diff -r 61fe62428855 -r 98f18622767c mpn/generic/toom_eval_pm2exp.c
--- a/mpn/generic/toom_eval_pm2exp.c	Wed Dec 23 17:31:50 2009 +0100
+++ b/mpn/generic/toom_eval_pm2exp.c	Wed Dec 23 18:41:05 2009 +0100
@@ -40,6 +40,7 @@
 #endif
 
   ASSERT (k >= 3);
+  ASSERT (shift*k < GMP_NUMB_BITS);
 
   ASSERT (hn > 0);
   ASSERT (hn <= n);
@@ -106,8 +107,11 @@
   mpn_add_n (xp2, xp2, tp, n + 1);
 #endif /* !HAVE_NATIVE_mpn_add_n_sub_n */
 
-  ASSERT (xp2[n] < ((1<<((k+1)*shift))-1)/((1<<shift)-1));
-  ASSERT (xm2[n] < ((1<<((k+2)*shift))-((k&1)?(1<<shift):1))/((1<<(2*shift))-1));
+  /* FIXME: the following asserts are useless if (k+1)*shift >= GMP_LIMB_BITS */
+  ASSERT ((k+1)*shift >= GMP_LIMB_BITS ||
+	  xp2[n] < ((CNST_LIMB(1)<<((k+1)*shift))-1)/((CNST_LIMB(1)<<shift)-1));
+  ASSERT ((k+2)*shift >= GMP_LIMB_BITS ||
+	  xm2[n] < ((CNST_LIMB(1)<<((k+2)*shift))-((k&1)?(CNST_LIMB(1)<<shift):1))/((CNST_LIMB(1)<<(2*shift))-1));
 
   return neg;
 }


More information about the gmp-commit mailing list