https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97266
Bug ID: 97266 Summary: "enum constant in boolean context" warning seems incorrect Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mfarazma.ext at gmail dot com Target Milestone: --- ``` #include <iostream> enum ValidateFlag : int8_t { a = 0, b , c }; int main(){ bool t = static_cast<bool>(c); return static_cast<int>(t); } ``` Compiling the above code with `g++ -Wall test.cc` generates this warning: warning: enum constant in boolean context [-Wint-in-bool-context] The behaviour doesn't seem correct as `c` is just an `int8_t` value, and casting an `int8_t` value to `bool` does not generate any warnings: ``` int8_t c = 2; bool t = static_cast<bool>(c); return static_cast<int>(t); ``` Having only 2 values in the enum also makes it compile fine: ``` enum ValidateFlag : int8_t { a = 0, c }; ```