]> Savannah Git Hosting - gnulib.git/commitdiff
ilogbl: Work around a Cygwin 3.4.6 bug.
authorBruno Haible <bruno@clisp.org>
Tue, 18 Apr 2023 11:24:42 +0000 (13:24 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 21 Apr 2023 15:24:44 +0000 (17:24 +0200)
* m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Also test the value of
ilogbl(NaN).
* doc/posix-functions/ilogbl.texi: Mention the new Cygwin bug.

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

index 39371b887c892c1b324dbf32c3002122d1d091ae..8bbfb0978d2ef71309682fe5ba151706343dcd6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-04-18  Bruno Haible  <bruno@clisp.org>
+
+       ilogbl: Work around a Cygwin 3.4.6 bug.
+       * m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Also test the value of
+       ilogbl(NaN).
+       * doc/posix-functions/ilogbl.texi: Mention the new Cygwin bug.
+
 2023-04-18  Bruno Haible  <bruno@clisp.org>
 
        file-has-acl tests: Avoid test failures on Cygwin 3.4.6.
index a038376f880d89bbb325235eb62dbfb6e9e0d38d..dab44c8367bc5489b13df4b0adaa57dd20615bd1 100644 (file)
@@ -16,6 +16,10 @@ This function returns a wrong result for a zero argument on some platforms:
 @c https://cygwin.com/ml/cygwin/2019-12/msg00074.html
 Cygwin 2.9.
 @item
+This function returns a wrong result for a NaN argument on some platforms:
+@c https://cygwin.com/pipermail/cygwin/2023-April/253511.html
+Cygwin 3.4.6.
+@item
 This function returns a wrong result for denormalized arguments on some platforms:
 AIX 7.1 64-bit, Haiku 2017.
 @end itemize
index e05907b896580240332a3ebc044f410e00e05090..b25323e95f2cb9db9f06a2142dd22da8c18a7a4b 100644 (file)
@@ -1,5 +1,5 @@
-# ilogbl.m4 serial 5
-dnl Copyright (C) 2010-2022 Free Software Foundation, Inc.
+# ilogbl.m4 serial 6
+dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -72,6 +72,7 @@ AC_DEFUN([gl_FUNC_ILOGBL],
 
 dnl Test whether ilogbl() works.
 dnl On Cygwin 2.9, ilogbl(0.0L) is wrong.
+dnl On Cygwin 3.4.6, ilogbl(NaN) is wrong.
 dnl On AIX 7.1 in 64-bit mode, ilogbl(2^(LDBL_MIN_EXP-1)) is wrong.
 dnl On Haiku 2017, it returns i-2 instead of i-1 for values between
 dnl ca. 2^-16444 and ca. 2^-16382.
@@ -104,6 +105,17 @@ AC_DEFUN([gl_FUNC_ILOGBL_WORKS],
 #  define LDBL_MIN_EXP DBL_MIN_EXP
 # endif
 #endif
+/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the
+   runtime type conversion.  */
+#ifdef __sgi
+static long double NaNl ()
+{
+  double zero = 0.0;
+  return zero / zero;
+}
+#else
+# define NaNl() (0.0L / 0.0L)
+#endif
 volatile long double x;
 static int dummy (long double x) { return 0; }
 int main (int argc, char *argv[])
@@ -116,6 +128,12 @@ int main (int argc, char *argv[])
     if (my_ilogbl (x) != FP_ILOGB0)
       result |= 1;
   }
+  /* This test fails on Cygwin 3.4.6.  */
+  {
+    x = NaNl ();
+    if (my_ilogbl (x) != FP_ILOGBNAN)
+      result |= 2;
+  }
   /* This test fails on AIX 7.1 in 64-bit mode.  */
   {
     int i;
@@ -123,7 +141,7 @@ int main (int argc, char *argv[])
     for (i = LDBL_MIN_EXP - 1; i < 0; i++)
       x = x * 0.5L;
     if (x > 0.0L && my_ilogbl (x) != LDBL_MIN_EXP - 2)
-      result |= 2;
+      result |= 4;
   }
   /* This test fails on Haiku 2017.  */
   {
@@ -131,7 +149,7 @@ int main (int argc, char *argv[])
     for (i = 1, x = (long double)1.0; i >= LDBL_MIN_EXP-100 && x > (long double)0.0; i--, x *= (long double)0.5)
       if (my_ilogbl (x) != i - 1)
         {
-          result |= 4;
+          result |= 8;
           break;
         }
   }