From: Bruno Haible Date: Sun, 4 Sep 2022 02:48:31 +0000 (+0200) Subject: fmal: Work around glibc 2.17 bug on x86_64. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=176009552f42d6794c5b634f42e95ab20b63e62c;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 431a6e6b7b..ab704f1510 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-09-03 Bruno Haible + + 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 Fix a compilation error in C++ mode on Solaris 11.4. diff --git a/doc/posix-functions/fmal.texi b/doc/posix-functions/fmal.texi index 1c9db7a9c0..99223b317a 100644 --- a/doc/posix-functions/fmal.texi +++ b/doc/posix-functions/fmal.texi @@ -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: diff --git a/m4/fmal.m4 b/m4/fmal.m4 index c7d4f346e2..9d78a2817b 100644 --- a/m4/fmal.m4 +++ b/m4/fmal.m4 @@ -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],