https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97266
--- Comment #2 from m farazma <mfarazma.ext at gmail dot com> --- (In reply to Jonathan Wakely from comment #1) > (In reply to m farazma from comment #0) > > ``` > > #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, > > No it isn't. In C enumerators are just integers, but in C++ they have the > same type as the enumeration type they belong to. > But isn't the type of the enum set to be `int8_t` in this example? In which case casting from `int8_t` to `bool` should be straight forward and without warnings.