Using GCC, if you switch on an enum value and one of the enums is missing a case statement a warning will be emitted. When you add a default item the warning will no longer be emitted, which makes sense in the general case.
Is there a way to use a default statement and still have a warning if not all the enum values are covered? Since my function may deal with impure input I’d like to cover the generic case but still get compiler warnings about missing an enum case.
Currently I end up assigning a default after the switch statement.
-Wswitch-enum, but unluckily only the most recent version supports this.
(You could of course simulate the behaviour that you want by using a goto outside the switch and omitting the default, but I would strongly advise against that, it’s ugly and someone else reading your code would have a WTF experience.)