bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: limits-h: Work around a clang 15 bug


From: Bruno Haible
Subject: Re: limits-h: Work around a clang 15 bug
Date: Thu, 09 Feb 2023 16:11:53 +0100

I wrote:
> 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.
>       * doc/posix-headers/limits.texi: Mention the clang bug.

Oops, that was not sufficient. This patch is needed as well:


diff --git a/ChangeLog b/ChangeLog
index fc3663eedc..f0d757837e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        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>
diff --git a/lib/limits.in.h b/lib/limits.in.h
index eaeac47229..a01b4c6a28 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -119,11 +119,14 @@
 
 /* Macros specified by C23.  */
 
-#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 */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]