diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-24 13:47:38 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-24 13:47:38 +0000 |
commit | b523c7635a6e15f474d67ae9ce044a907dde0b5a (patch) | |
tree | 53f9f658326150efb4aae8654d64f5cf3219bedd | |
parent | 9e23229437b7fd46ea6810245d03798896af2c44 (diff) | |
download | mpfr-b523c7635a6e15f474d67ae9ce044a907dde0b5a.tar.gz |
[tests/tfmma.c] Added extreme_underflow test: before the r13798 bug fix,
this was triggering an integer overflow.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13805 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tfmma.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/tfmma.c b/tests/tfmma.c index a4243cca2..34567bd5a 100644 --- a/tests/tfmma.c +++ b/tests/tfmma.c @@ -577,6 +577,26 @@ bug20200206 (void) mpfr_set_emin (emin); } +/* check for integer overflow (see bug fixed in r13798) */ +static void +extreme_underflow (void) +{ + mpfr_t x, y, z; + mpfr_exp_t emin = mpfr_get_emin (); + + set_emin (MPFR_EMIN_MIN); + mpfr_inits2 (64, x, y, z, (mpfr_ptr) 0); + mpfr_set_ui_2exp (x, 1, MPFR_EMIN_MIN - 1, MPFR_RNDN); + mpfr_set (y, x, MPFR_RNDN); + mpfr_nextabove (x); + mpfr_clear_flags (); + mpfr_fmms (z, x, x, y, y, MPFR_RNDN); + MPFR_ASSERTN (__gmpfr_flags == (MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT)); + MPFR_ASSERTN (MPFR_IS_ZERO (z) && MPFR_IS_POS (z)); + mpfr_clears (x, y, z, (mpfr_ptr) 0); + set_emin (emin); +} + /* Test double-rounding cases in mpfr_set_1_2, which is called when all the precisions are the same. With set.c before r13347, this triggers errors for neg=0. */ @@ -655,6 +675,7 @@ main (int argc, char *argv[]) half_plus_half (); bug20170405 (); double_rounding (); + extreme_underflow (); tests_end_mpfr (); return 0; |