[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
limits-h: Work around a clang 15 bug
From: |
Bruno Haible |
Subject: |
limits-h: Work around a clang 15 bug |
Date: |
Thu, 09 Feb 2023 13:33:58 +0100 |
When compiling a Gnulib testdir with clang15 with -std=gnu2x option,
I see this compilation error:
../../gltests/test-limits-h.c:113:22: error: use of undeclared identifier
'BOOL_MAX'
int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH };
^
../../gltests/test-limits-h.c:114:16: error: use of undeclared identifier
'BOOL_MAX'
static_assert (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
^
2 errors generated.
make[4]: *** [Makefile:23558: test-limits-h.o] Error 1
The reason is that clang's <limits.h> defines BOOL_WIDTH but not BOOL_MAX.
This patch provides a workaround.
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.
diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index 22dc4239f7..09440cac8d 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -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}:
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
index 5088fa16fd..4f8ce41098 100644
--- a/m4/limits-h.m4
+++ b/m4/limits-h.m4
@@ -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])])
- limits-h: Work around a clang 15 bug,
Bruno Haible <=