[LLVMbugs] [Bug 6976] New: autoconf test for <stdbool.h> fails
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Apr 29 10:44:21 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=6976
Summary: autoconf test for <stdbool.h> fails
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Headers
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: pipping.elias at gmail.com
CC: llvmbugs at cs.uiuc.edu
Here's the error:
conftest.c:84:16: error: initializer element is not a compile-time constant
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
here's where it comes from:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "strace"
| #define PACKAGE_TARNAME "strace"
| #define PACKAGE_VERSION "4.5.20"
| #define PACKAGE_STRING "strace 4.5.20"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "strace"
| #define VERSION "4.5.20"
| #define LINUX 1
| #define X86_64 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _ALL_SOURCE 1
| #define _GNU_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| #define STDC_HEADERS 1
| /* end confdefs.h. */
|
| #include <stdbool.h>
| #ifndef bool
| "error: bool is not defined"
| #endif
| #ifndef false
| "error: false is not defined"
| #endif
| #if false
| "error: false is not 0"
| #endif
| #ifndef true
| "error: true is not defined"
| #endif
| #if true != 1
| "error: true is not 1"
| #endif
| #ifndef __bool_true_false_are_defined
| "error: __bool_true_false_are_defined is not defined"
| #endif
|
| struct s { _Bool s: 1; _Bool t; } s;
|
| char a[true == 1 ? 1 : -1];
| char b[false == 0 ? 1 : -1];
| char c[__bool_true_false_are_defined == 1 ? 1 : -1];
| char d[(bool) 0.5 == true ? 1 : -1];
| bool e = &s;
| char f[(_Bool) 0.0 == false ? 1 : -1];
| char g[true];
| char h[sizeof (_Bool)];
| char i[sizeof s.t];
| enum { j = false, k = true, l = false * true, m = true * 256 };
| /* The following fails for
| HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
| _Bool n[m];
| char o[sizeof n == m * sizeof n[0] ? 1 : -1];
| char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
| # if defined __xlc__ || defined __GNUC__
| /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
| reported by James Lemley on 2005-10-05; see
|
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
| This test is not quite right, since xlc is allowed to
| reject this program, as the initializer for xlcbug is
| not one of the forms that C requires support for.
| However, doing the test right would require a runtime
| test, and that would make cross-compilation harder.
| Let us hope that IBM fixes the xlc bug, and also adds
| support for this kind of constant expression. In the
| meantime, this test will reject xlc, which is OK, since
| our stdbool.h substitute should suffice. We also test
| this with GCC, where it should work, to detect more
| quickly whether someone messes up the test in the
| future. */
| char digs[] = "0123456789";
| int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
| # endif
| /* Catch a bug in an HP-UX C compiler. See
| http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
| */
| _Bool q = true;
| _Bool *pq = &q;
|
| int
| main ()
| {
|
| *pq |= q;
| *pq |= ! q;
| /* Refer to every declared value, to avoid compiler optimizations. */
| return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
| + !m + !n + !o + !p + !q + !pq);
|
| ;
| return 0;
| }
I'm not sure who's at fault here. This does mean that clang can't compile
strace right away, though, because configure (generated by autoconf 2.65)
considers clang's <stdbool.h> useless and the type bool is used in the code
(albeit for exactly one variable).
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list