[cfe-dev] [libcxx]: a testsuite bug involving boolean type and values

ZhangXiongpang zhangxiongpang at gmail.com
Tue Oct 9 22:53:46 PDT 2012


I saw the code in
    test/depr/depr.c.headers/stdbool_h.pass.cpp
as follows:
--------------------------------------------------
#include <stdbool.h>

#ifndef __bool_true_false_are_defined
#error __bool_true_false_are_defined not defined
#endif

#ifdef bool // why bool should not be defined?
#error bool should not be defined
#endif

#ifdef true // idem
#error true should not be defined
#endif

#ifdef false // idem
#error false should not be defined
#endif
--------------------------------------------------

Why bool/true/false should not be defined?
Is it a bug of the stdbool_h.pass.cpp?
I think it should be:
--------------------------------------------------
#ifndef bool
#error bool should not defined
#endif

#ifndef true
#error true should not defined
#endif

#ifndef false
#error false should not defined
#endif
--------------------------------------------------

Because the section 7.18 of  n1548.pdf
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf>   says:
--------------------------------------------------
7.18 Boolean type and values <stdbool.h>
1 The header <stdbool.h> defines four macros.
2 The macro bool expands to _Bool.
3 The remaining three macros are suitable for use in #if preprocessing
directives. They are true which expands to the integer constant 1, false
which expands to the integer constant 0, and _bool_true_false_are_defined
which expands to the integer constant 1.
--------------------------------------------------



--
View this message in context: http://clang-developers.42468.n3.nabble.com/libcxx-a-testsuite-bug-involving-boolean-type-and-values-tp4027262.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list