From: Bruno Haible Date: Thu, 9 Feb 2023 15:08:00 +0000 (+0100) Subject: limits-h: Work around a clang 15 bug. X-Git-Tag: v1.0~1686 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=962a577b7685e0aa938b8241460c12484ae725c3;p=gnulib.git 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. --- 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 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 */