diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-05-21 08:23:21 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-05-21 08:23:21 +0000 |
commit | c4a7352106c9b6e6b1faea61409146071bf00981 (patch) | |
tree | 166f1868fce2c313030c736e315c46e03a330527 /sub1sp.c | |
parent | 4aa2e4229de04c3b3d3a6b3bd339a20cba1ea93e (diff) | |
download | mpfr-c4a7352106c9b6e6b1faea61409146071bf00981.tar.gz |
initialize bbcp and bbcp1 to -1 (should be invalid)
added MPFR_ASSERTN to check they are not -1 before reads
simplified a test: (rnd == RNDN) || (rnd != RNDZ) ==> rnd != RNDZ
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5358 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub1sp.c')
-rw-r--r-- | sub1sp.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -142,9 +142,9 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) mp_limb_t limb; int inexact; mp_limb_t bcp,bcp1; /* Cp and C'p+1 */ - mp_limb_t bbcp = (mp_limb_t) b, bbcp1 = (mp_limb_t) c; /* Cp+1 and C'p+2, + mp_limb_t bbcp = (mp_limb_t) -1, bbcp1 = (mp_limb_t) -1; /* Cp+1 and C'p+2, gcc claims that they might be used - uninitialized. We fill them with dummy + uninitialized. We fill them with invalid values, which should produce a failure if so. */ MPFR_TMP_DECL(marker); @@ -652,6 +652,8 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /* Final exponent -1 since we have shifted the mantissa */ bx--; /* Update bcp and bcp1 */ + MPFR_ASSERTN(bbcp != (mp_limb_t) -1); + MPFR_ASSERTN(bbcp1 != (mp_limb_t) -1); bcp = bbcp; bcp1 = bbcp1; /* We dont't have anymore a valid Cp+1! @@ -698,6 +700,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) DEBUG( printf("(SubOneUlp)Cp=%d, Cp+1=%d C'p+1=%d\n", bcp!=0,bbcp!=0,bcp1!=0)); /* Compute the last bit (Since we have shifted the mantissa) we need one more bit!*/ + MPFR_ASSERTN(bbcp != (mp_limb_t) -1); if ( (rnd_mode == GMP_RNDZ && bcp==0) || (rnd_mode==GMP_RNDN && bbcp==0) || (bcp && bcp1==0) ) /*Exact result*/ @@ -747,7 +750,9 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) bbcp=0; DEBUG( printf("(Truncate) Cp=%d, Cp+1=%d C'p+1=%d C'p+2=%d\n", \ bcp!=0, bbcp!=0, bcp1!=0, bbcp1!=0) ); - if (( ((rnd_mode == GMP_RNDN) || (rnd_mode != GMP_RNDZ)) && bcp) + MPFR_ASSERTN(bbcp != (mp_limb_t) -1); + MPFR_ASSERTN((rnd_mode != GMP_RNDN) || (bcp != 0) || (bbcp == 0) || (bbcp1 != (mp_limb_t) -1)); + if (((rnd_mode != GMP_RNDZ) && bcp) || ((rnd_mode == GMP_RNDN) && (bcp == 0) && (bbcp) && (bbcp1))) { |