https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87951
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #12) > It's not a useless warning. If I call your function from comment 7 like > this, I get undefined behaviour: > > CoverMyBases( Enum{2} ); > > Your switch is undefined for this code. That's what GCC is warning you > about. To tell GCC you will never call the function with any value except > Enum::A or Enum::B, add > > default: __builtin_unreachable(); Maybe better to add it after the switch if you want to make sure that you get a warning with -Wswitch if a new enumerator is added.