]> Savannah Git Hosting - gnulib.git/commitdiff
limits-h: Work around a clang 15 bug.
authorBruno Haible <bruno@clisp.org>
Thu, 9 Feb 2023 12:30:04 +0000 (13:30 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Feb 2023 03:24:50 +0000 (04:24 +0100)
* m4/limits-h.m4 (gl_LIMITS_H): Test also for BOOL_MAX.
* lib/limits.in.h: Handle the case where BOOL_WIDTH is present and
BOOL_MAX is missing.
* doc/posix-headers/limits.texi: Mention the clang bug.

ChangeLog
doc/posix-headers/limits.texi
lib/limits.in.h
m4/limits-h.m4

index 66b0c6f7aa38a973527ff674f1b70aee15718012..4f322a4670dbd3867de6dbe4b6d9641b476fb5e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-09  Bruno Haible  <bruno@clisp.org>
+
+       limits-h: Work around a clang 15 bug.
+       * m4/limits-h.m4 (gl_LIMITS_H): Test also for BOOL_MAX.
+       * lib/limits.in.h: Handle the case where BOOL_WIDTH is present and
+       BOOL_MAX is missing.
+       * doc/posix-headers/limits.texi: Mention the clang bug.
+
 2023-02-09  Bruno Haible  <bruno@clisp.org>
 
        Fix error in C++ mode on glibc systems (regression 2022-04-28).
index 22dc4239f7d54b1ccba3da021ba1720209d86679..09440cac8d66d3f8a7d92d93a05fb4c7dd768817 100644 (file)
@@ -21,6 +21,9 @@ glibc 2.24, NetBSD 9.0, many others.
 The macros @code{BOOL_MAX} and @code{BOOL_WIDTH} are not defined on
 some platforms:
 glibc 2.32, many others.
+@item
+The macro @code{BOOL_MAX} is not defined with some compilers:
+clang 15.0.6.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{gethostname}:
index b77bf75c5fec9b51f58eb6fa41d1db794973be8e..03815ab7835ab03e296fa67ce1910ba9b30496e7 100644 (file)
@@ -1,6 +1,6 @@
 /* A GNU-like <limits.h>.
 
-   Copyright 2016-2022 Free Software Foundation, Inc.
+   Copyright 2016-2023 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
 
 /* Macros specified by C2x.  */
 
-#if (! defined BOOL_WIDTH \
-     && (defined _GNU_SOURCE \
-         || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
-# define BOOL_MAX 1
-# define BOOL_WIDTH 1
+#if (defined _GNU_SOURCE \
+     || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
+# if ! defined BOOL_WIDTH
+#  define BOOL_WIDTH 1
+#  define BOOL_MAX 1
+# elif ! defined BOOL_MAX
+#  define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
+# endif
 #endif
 
 #endif /* _@GUARD_PREFIX@_LIMITS_H */
index 5d5a5bf584d81bbee26b17b172b6748e346f7a39..4f8ce41098a96a2eea7c80be38051c3e9c76e5ec 100644 (file)
@@ -1,6 +1,6 @@
 dnl Check whether limits.h has needed features.
 
-dnl Copyright 2016-2022 Free Software Foundation, Inc.
+dnl Copyright 2016-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.
@@ -23,6 +23,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
             int wb = WORD_BIT;
             int ullw = ULLONG_WIDTH;
             int bw = BOOL_WIDTH;
+            int bm = BOOL_MAX;
           ]])],
        [gl_cv_header_limits_width=yes],
        [gl_cv_header_limits_width=no])])