On 10/04/2016 06:33 AM, Jaroslav Skarvada wrote:
In fact it's glibc, affected version: glibc-2.24.90-8

I sent a heads-up about this to libc-alpha, here:

https://sourceware.org/ml/libc-alpha/2016-10/msg00044.html

Something like the attached gnulib patch should work around the problem, but I wonder whether we should bother given that it's bleeding-edge glibc that will get fixed soon and that the failure is so unimportant.

diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index 7658326..135a51a 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -14,6 +14,9 @@ IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.
 @item
 Macros like @code{CHAR_WIDTH} are not defined on some platforms:
 glibc 2.24, many others.
+@item
+Macros like @code{LONG_WIDTH} have the wrong value on some platforms:
+glibc-2.24.90-8.fc26.i686.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/lib/limits.in.h b/lib/limits.in.h
index 9a4f9f4..b616a4e 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -44,6 +44,21 @@
 
 /* Macros specified by ISO/IEC TS 18661-1:2014.  */
 
+/* Work around a bug in glibc-2.24.90-8.fc26.i686.  */
+#if defined LONG_WIDTH && LONG_MAX >> (LONG_WIDTH - 2) != 1
+# undef CHAR_WIDTH
+# undef SCHAR_WIDTH
+# undef UCHAR_WIDTH
+# undef SHRT_WIDTH
+# undef USHRT_WIDTH
+# undef INT_WIDTH
+# undef UINT_WIDTH
+# undef LONG_WIDTH
+# undef ULONG_WIDTH
+# undef LLONG_WIDTH
+# undef ULLONG_WIDTH
+#endif
+
 #if (! defined ULLONG_WIDTH                                             \
      && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
 # define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
index 31fdf0a..fd12c57 100644
--- a/m4/limits-h.m4
+++ b/m4/limits-h.m4
@@ -18,6 +18,9 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
                            #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
                           #endif
                           #include <limits.h>
+                          #if LONG_MAX >> (LONG_WIDTH - 2) != 1
+                            error LONG_WIDTH is wrong, e.g., glibc-2.24.90-8;
+                          #endif
                           int ullw = ULLONG_WIDTH;]])],
        [gl_cv_header_limits_width=yes],
        [gl_cv_header_limits_width=no])])

Reply via email to