]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Do not allow divide-by-zero exception for pow(+/- 0, -Inf).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 17 Oct 2018 21:23:40 +0000 (21:23 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 17 Oct 2018 21:23:40 +0000 (21:23 +0000)
C99 wrongly specified a divide-by-zero exception for pow(+/- 0, -Inf);
C11 made it optional after this was pointed out, and the permission
for this exception has been removed in the current C2x draft.  This
patch makes the glibc pow tests reflect the stricter requirement
(which follows the normal IEEE rules that a divide-by-zero exception
is for the case of exact infinite results from *finite* operands, not
for such results when any operand is infinite).

Tested for x86_64 and x86.  (If any other pow implementation in glibc,
not exercised on those architectures, turns out to fail the stricter
test, it should be fixed to avoid the exception in this case.)

* math/libm-test-pow.inc (pow_test_data): Do not allow
divide-by-zero exception for pow(+/- 0, -Inf).

ChangeLog
math/libm-test-pow.inc

index 7dea006c16acf26686f11133147ad8cbc06211ac..450732e565c21f544373d3adb680f96ae26e3144 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-17  Joseph Myers  <joseph@codesourcery.com>
+
+       * math/libm-test-pow.inc (pow_test_data): Do not allow
+       divide-by-zero exception for pow(+/- 0, -Inf).
+
 2018-10-17  Zack Weinberg  <zackw@panix.com>
 
        * manual/job.texi (Job Control is Optional): Remove node, as
index ff20ad2f044cd29e542e63f376d897073ead6dd0..c7b91c1131440af02c326efcc015d2219373ea1c 100644 (file)
@@ -248,8 +248,13 @@ static const struct test_ff_f_data pow_test_data[] =
 
     TEST_ff_f (pow, 0, plus_infty, 0, ERRNO_UNCHANGED),
     TEST_ff_f (pow, minus_zero, plus_infty, 0, ERRNO_UNCHANGED),
-    TEST_ff_f (pow, 0, minus_infty, plus_infty, DIVIDE_BY_ZERO_EXCEPTION_OK|ERRNO_UNCHANGED),
-    TEST_ff_f (pow, minus_zero, minus_infty, plus_infty, DIVIDE_BY_ZERO_EXCEPTION_OK|ERRNO_UNCHANGED),
+    /* C99 erroneously specified a divide-by-zero exception here,
+       which is not permitted in C2x (C11 specified it as optional).
+       See <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1515.pdf>
+       and
+       <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2271.pdf>.  */
+    TEST_ff_f (pow, 0, minus_infty, plus_infty, ERRNO_UNCHANGED),
+    TEST_ff_f (pow, minus_zero, minus_infty, plus_infty, ERRNO_UNCHANGED),
 
     /* pow (x, +inf) == +inf for |x| > 1.  */
     TEST_ff_f (pow, 1.5, plus_infty, plus_infty, ERRNO_UNCHANGED|NO_TEST_INLINE),