diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-01-19 06:51:13 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2007-01-19 06:51:13 +0000 |
commit | 09d5c485a74847a82aee17c5cc51052049718682 (patch) | |
tree | 58430d5492a96ac7d6f84da37d46dd42909f7006 /tests | |
parent | a4cab95f8d3feee4285f75222b31baa8cc7b4081 (diff) | |
download | mpfr-09d5c485a74847a82aee17c5cc51052049718682.tar.gz |
tests/tpow.c: added a test which fails (undetected integer overflow).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4342 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tpow.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tpow.c b/tests/tpow.c index a153f4188..9d2161dca 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -297,6 +297,22 @@ check_pow_si (void) MPFR_ASSERTN (mpfr_cmp_si_2exp (x, 1, LONG_MIN)); } + mpfr_set_si (x, 2, GMP_RNDN); + mpfr_pow_si (x, x, LONG_MIN + 1, GMP_RNDN); /* 2^(LONG_MIN+1) */ + if (mpfr_nan_p (x)) + { + printf ("Error in pow_si(2, LONG_MIN+1): got NaN\n"); + exit (1); + } + if (LONG_MIN + 2 < mpfr_get_emin ()) + { + MPFR_ASSERTN (mpfr_zero_p (x)); + } + else + { + MPFR_ASSERTN (mpfr_cmp_si_2exp (x, 1, LONG_MIN + 1)); + } + mpfr_set_si_2exp (x, 1, -1, GMP_RNDN); /* 0.5 */ mpfr_pow_si (x, x, LONG_MIN, GMP_RNDN); /* 2^(-LONG_MIN) */ if (LONG_MIN < 1 - mpfr_get_emax ()) /* 1 - LONG_MIN > emax */ |