No warning for implicit cast of bool to floating type?
问题 Looks like this snippet compiles in clang without warning, even with -Weverything: double x; ... if (fabs(x > 1.0)) { ... } Am I missing something? Or do the compiler and C++ standard think that casting bool to double is something that makes sense? 回答1: This is a consequence of making bool an integral type. According to C++ standard, section 3.9.1.6 Values of type bool are either true or false (Note: There are no signed , unsigned , short , or long bool types or values. — end note) Values of