]> Savannah Git Hosting - gnulib.git/commitdiff
fmal: Work around glibc 2.17 bug on x86_64.
authorBruno Haible <bruno@clisp.org>
Sun, 4 Sep 2022 02:48:31 +0000 (04:48 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 5 Sep 2022 01:54:42 +0000 (03:54 +0200)
* m4/fmal.m4 (gl_FUNC_FMAL_WORKS): Test against bug seen on glibc 2.17
x86_64.
* doc/posix-functions/fmal.texi: Update info.

ChangeLog
doc/posix-functions/fmal.texi
m4/fmal.m4

index 431a6e6b7b57c6f7ce2740d11c490522b137f916..ab704f151078c561feb45580f7e8ecc525a16592 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-09-03  Bruno Haible  <bruno@clisp.org>
+
+       fmal: Work around glibc 2.17 bug on x86_64.
+       * m4/fmal.m4 (gl_FUNC_FMAL_WORKS): Test against bug seen on glibc 2.17
+       x86_64.
+       * doc/posix-functions/fmal.texi: Update info.
+
 2022-09-03  Bruno Haible  <bruno@clisp.org>
 
        Fix a compilation error in C++ mode on Solaris 11.4.
index 1c9db7a9c0e84cb13feec1d30fd742a75307c5e4..99223b317a203d2d4a4873997a5c5e6d1222d81b 100644 (file)
@@ -13,7 +13,7 @@ This function is missing on some platforms:
 FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin 1.7.x, MSVC 9, Android 4.4.
 @item
 This function produces wrong results on some platforms:
-glibc 2.11, macOS 10.13, FreeBSD 6.4/x86, mingw.
+glibc 2.17, macOS 10.13, FreeBSD 6.4/x86, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index c7d4f346e23569d843c1131a3748dae7bbd9b07d..9d78a2817bd57c8c1433ef541272fa56cd651e2a 100644 (file)
@@ -1,4 +1,4 @@
-# fmal.m4 serial 7
+# fmal.m4 serial 8
 dnl Copyright (C) 2011-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -65,7 +65,8 @@ AC_DEFUN([gl_FUNC_FMAL],
   AC_SUBST([FMAL_LIBM])
 ])
 
-dnl Test whether fmal() has any of the 15 known bugs of glibc 2.11.3 on x86_64.
+dnl Test whether fmal() has any of the 15 known bugs of glibc 2.11.3 on x86_64
+dnl or the known bug of glibc 2.17 on x86_64.
 AC_DEFUN([gl_FUNC_FMAL_WORKS],
 [
   AC_REQUIRE([AC_PROG_CC])
@@ -365,6 +366,20 @@ int main()
     if (result != expected)
       failed_tests |= 32;
   }
+  /* This test fails on glibc 2.17 x86_64.  */
+  {
+    volatile long double x = 1.0L;
+    volatile long double y = x;
+    volatile long double z = - ldexpl (1.0L, -1 - LDBL_MANT_DIG); /* - 2^-65 */
+    /* x * y + z with infinite precision: 2^0 - 2^-65.
+       Lies between 2^0 - 2^-64 and 2^0 and is at the same distance from each.
+       According to the round-to-even rule, the rounding must round up and
+       produce 2^0.  */
+    volatile long double expected = 1.0L;
+    volatile long double result = fmal (x, y, z);
+    if (result != expected)
+      failed_tests |= 64;
+  }
   return failed_tests;
 }]])],
         [gl_cv_func_fmal_works=yes],