Is (bool) cast reliably 0 or 1? [duplicate]
问题 This question already has answers here : Casting int to bool in C/C++ (3 answers) Closed 3 months ago . From some reading on Stack Overflow, I gather that bool , as defined in stdbool.h , is a macro that expands to the built-in type _Bool , and that true is defined as 1 and false is defined as 0 . Is casting to bool guaranteed to return a value of 0 or 1 ? Might a _Bool variable, including cast rvalues, ever attain a value other than 0 or 1? The following code implies that _Bool variables,