]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
fma: Work around glibc 2.43 regression.
authorBruno Haible <bruno@clisp.org>
Wed, 27 May 2026 17:08:16 +0000 (19:08 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 27 May 2026 17:08:46 +0000 (19:08 +0200)
* m4/fma.m4 (gl_FUNC_FMA_WORKS): Check against glibc 2.43 bug.
* doc/posix-functions/fma.texi: Mention glibc 2.43 as being buggy.

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

index 1e68c41618a9c96e26b2fda2a1fbd85c263340e2..838fcc0d6357c2dc550d207750cb85a98f07d57b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-05-27  Bruno Haible  <bruno@clisp.org>
+
+       fma: Work around glibc 2.43 regression.
+       * m4/fma.m4 (gl_FUNC_FMA_WORKS): Check against glibc 2.43 bug.
+       * doc/posix-functions/fma.texi: Mention glibc 2.43 as being buggy.
+
 2026-05-26  Paul Eggert  <eggert@cs.ucla.edu>
 
        libgmp-mpz: pacify -Wuseless-cast
index ec45e5286d6133c036d354f58edec018b70a3742..9be058efea8ad335f49e9364864f11060fe801ed 100644 (file)
@@ -15,7 +15,9 @@ 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, Solaris 9, MSVC 9.
 @item
 This function produces wrong results on some platforms:
-glibc 2.11, Mac OS X 10.5, FreeBSD 6.4/x86, NetBSD 8.0, OpenBSD 7.4/arm64, Cygwin 1.5, mingw.
+@c https://sourceware.org/bugzilla/show_bug.cgi?id=34183
+glibc 2.43,
+Mac OS X 10.5, FreeBSD 6.4/x86, NetBSD 8.0, OpenBSD 7.4/arm64, Cygwin 1.5, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 49c705df6c1e7b54daf1091f895f62eb1be20931..cf9d7b888a460337fd5ebcc93e17034d48882136 100644 (file)
--- a/m4/fma.m4
+++ b/m4/fma.m4
@@ -1,5 +1,5 @@
 # fma.m4
-# serial 9
+# serial 10
 dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -52,7 +52,8 @@ AC_DEFUN([gl_FUNC_FMA],
   AC_SUBST([FMA_LIBM])
 ])
 
-dnl Test whether fma() has any of the 7 known bugs of glibc 2.11.3 on x86_64.
+dnl Test whether fma() has any of the 7 known bugs of glibc 2.11.3 on x86_64
+dnl and the 1 known bug of glibc 2.43 on x86_64.
 AC_DEFUN([gl_FUNC_FMA_WORKS],
 [
   AC_REQUIRE([AC_PROG_CC])
@@ -134,6 +135,21 @@ int main()
        therefore the rounding must round down and produce (2^53 - 2^0).  */
     volatile double expected = ldexp (1.0, DBL_MANT_DIG) - 1.0;
     volatile double result = my_fma (x, y, z);
+    if (result != expected)
+      failed_tests |= 8;
+  }
+  /* This test fails on glibc 2.43 on x86_64.
+     <https://sourceware.org/bugzilla/show_bug.cgi?id=34183>  */
+  {
+    volatile double x = 1.0 + 1.0 / (double) (1U << 21); /* 2^0 + 2^-21 */
+    volatile double y = x; /* 2^0 + 2^-21 */
+    volatile double z = (double) (1U << 11); /* 2^11 */
+    /* x * y + z with infinite precision: 2^11 + 2^0 + 2^-20 + 2^-42.
+       Lies between (2^11 + 2^0 + 2^-20) and (2^11 + 2^0 + 2^-20 + 2^-41).
+       By the round-to-even rule, the rounding must round down and produce
+       (2^11 + 2^0 + 2^-20).  */
+    volatile double expected = 2049.00000095367431640625;
+    volatile double result = my_fma (x, y, z);
     if (result != expected)
       failed_tests |= 16;
   }