Hi, The macro AC_HEADER_STDBOOL (in gnulib: in stdbool.m4, in autoconf-2.59c: in headers.m4) rejects valid 'bool' implementations.
Seen with Sun C 5.9 ("c99 -Xa") for Linux/x86. The config.log contained: configure:30747: checking for stdbool.h that conforms to C99 configure:30806: /opt/sun/compilers-20060314/bin/c99 -Xa -c -xO5 -I/packages/inst-sunpro/include conftest.c >&5 "conftest.c", line 126: integral constant expression expected "conftest.c", line 126: zero or negative subscript "conftest.c", line 127: warning: improper pointer/integer combination: op "=" "conftest.c", line 128: integral constant expression expected "conftest.c", line 128: zero or negative subscript "conftest.c", line 144: warning: statement not reached c99: acomp failed for conftest.c The lines of the gnulib macro that this compiler rejects are: char d[(bool) -0.5 == true ? 1 : -1]; char f[(_Bool) -0.0 == false ? 1 : -1]; Let's take a close look: ============================= boolcast.c ============================= #include <stdbool.h> char ac[(int) 3.999 == 3 ? 1 : -1]; char am[((int) 3.999 == 3) * 2 - 1]; char dc[(bool) -0.5 == true ? 1 : -1]; char dm[((bool) -0.5 == true) * 2 - 1]; char fc[(_Bool) -0.0 == false ? 1 : -1]; char fm[((_Bool) -0.0 == false) * 2 - 1]; ====================================================================== $ c99 -Xa -c boolcast.c "boolcast.c", line 6: integral constant expression expected "boolcast.c", line 6: zero or negative subscript "boolcast.c", line 7: warning: can not declare variably modified type at file scope "boolcast.c", line 9: integral constant expression expected "boolcast.c", line 9: zero or negative subscript "boolcast.c", line 10: warning: can not declare variably modified type at file scope Why is the compiler right in signalling these errors? ISO C 99, section 6.6 paragraph 6, defines the term "integer constant expression": An _integer constant expression_ shall have integer type and shall only have operands that are integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, and floating constants that are the immediate operands of casts. Cast operators in an integer constant expression shall only convert arithmetic types to integer types, except as part of an operand to the sizeof operator. ISO C 99, section 6.2.5 paragraph 17, defines the term "integer types": The type char, the signed and unsigned integer types, and the enumerated types are collectively called integer types. So, _Bool and bool are _not_ integer types. => The expressions (bool) -0.5 and (_Bool) -0.0 are not casts converting to integer types. => Expressions containing (bool) -0.5 or (_Bool) -0.0 are not integer constant expressions. I suggest to remove these tests, because 1) the value of (bool) -0.5 or (_Bool) -0.0 cannot be tested in an AC_TRY_COMPILE and therefore cannot be cross-compiled. 2) gnulib's stdbool.h substitute cannot achieve (bool) -0.5 == true. Patch for gnulib: 2006-05-07 Bruno Haible <[EMAIL PROTECTED]> * stdbool.m4 (AC_HEADER_STDBOOL): Remove tests that convert a floating-point constant to bool; these are not integer constant expressions. *** stdbool.m4.bak 2006-01-26 14:32:38.000000000 +0100 --- stdbool.m4 2006-05-08 00:11:56.000000000 +0200 *************** *** 64,72 **** 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]; --- 64,70 ---- *************** *** 104,110 **** *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); ], [ac_cv_header_stdbool_h=yes], --- 102,108 ---- *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ ! return (!a + !b + !c + !e + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ], [ac_cv_header_stdbool_h=yes], Patch for autoconf: 2006-05-07 Bruno Haible <[EMAIL PROTECTED]> * lib/autoconf/headers.m4 (AC_HEADER_STDBOOL): Remove tests that convert a floating-point constant to bool; these are not integer constant expressions. *** autoconf-2.59c/lib/autoconf/headers.m4.bak 2006-04-10 20:27:24.000000000 +0200 --- autoconf-2.59c/lib/autoconf/headers.m4 2006-05-08 00:16:40.000000000 +0200 *************** *** 582,590 **** 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]; --- 582,588 ---- *************** *** 622,628 **** *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); ]])], [ac_cv_header_stdbool_h=yes], --- 620,626 ---- *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ ! return (!a + !b + !c + !e + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ]])], [ac_cv_header_stdbool_h=yes],