https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52763
--- Comment #10 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #8) > Clang warns when an enum object is compared to a constant that's out of the > most restricted range of the enum's type. The warning is in -Wall. It > doesn't warn when the object is compared to a constant that doesn't > correspond to any of the type's enumerators. I can see that being useful to > some (carefully written) projects but suspect it could be quite noisy for > many others. > > $ cat t.C && clang++ -S -Wall -Wextra t.C > enum E { NONE = 0, ONE = 1, TWO = 2 }; > > bool f (E e) > { > return e == 3; // no warning here > } > > bool g (E e) > { > return e == 4; > } > > > t.C:10:12: warning: comparison of constant 4 with expression of type 'E' is > always false [-Wtautological-constant-out-of-range-compare] > return e == 4; > ~ ^ ~ > 1 warning generated. Would it make sense for GCC to just reuse -Wenum-compare for this case instead of adding a new -Wtautological-constant-out-of-range-compare flag?