aboutsummaryrefslogtreecommitdiff
path: root/math/libm-test.inc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-03-29 17:22:14 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-03-29 17:22:14 +0000
commitea6029b19c6004c69a9074bf399091bbfbf58a0c (patch)
treea3f2488c38c5d4438f4dc08166a287825ffb60b1 /math/libm-test.inc
parent56737508002f1759da8d4d9944a8e98e58dce917 (diff)
downloadglibc-ea6029b19c6004c69a9074bf399091bbfbf58a0c.zip
glibc-ea6029b19c6004c69a9074bf399091bbfbf58a0c.tar.gz
glibc-ea6029b19c6004c69a9074bf399091bbfbf58a0c.tar.bz2
Fix scalb spurious "invalid" exceptions (bug 16770).
This patch fixes bug 16770, spurious "invalid" exceptions from scalb when testing whether the second argument is an integer, by inserting appropriate range checks to determine whether a cast to int is safe. (Note that invalid_fn is a function that handles both nonintegers and large integers, distinguishing them reliably using functions such as __rint; note also that there are no issues with scalb needing to avoid spurious "inexact" exceptions - it's an old-POSIX XSI function, not a standard C function bound to an IEEE 754 operation - although the return value is still fully determined.) Tested x86_64 and x86. [BZ #16770] * math/e_scalb.c (__ieee754_scalb): Check second argument is not too large before casting to int. * math/e_scalbf.c (__ieee754_scalbf): Likewise. * math/e_scalbl.c (__ieee754_scalbl): Likewise. * math/libm-test.inc (scalb_test_data): Add more tests.
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r--math/libm-test.inc17
1 files changed, 17 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index cefcb96..0eff34a 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -9134,6 +9134,23 @@ static const struct test_ff_f_data scalb_test_data[] =
TEST_ff_f (scalb, plus_infty, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
TEST_ff_f (scalb, qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_ff_f (scalb, max_value, max_value, plus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, max_value, -max_value, plus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, 1, max_value, plus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, 1, -max_value, plus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, min_value, max_value, plus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, min_value, -max_value, plus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, min_subnorm_value, max_value, plus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, min_subnorm_value, -max_value, plus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -max_value, max_value, minus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -max_value, -max_value, minus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -1, max_value, minus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -1, -max_value, minus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -min_value, max_value, minus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -min_value, -max_value, minus_uflow, UNDERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -min_subnorm_value, max_value, minus_oflow, OVERFLOW_EXCEPTION),
+ TEST_ff_f (scalb, -min_subnorm_value, -max_value, minus_uflow, UNDERFLOW_EXCEPTION),
+
TEST_ff_f (scalb, 0.8L, 4, 12.8L),
TEST_ff_f (scalb, -0.854375L, 5, -27.34L),
};