https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70412
Bug ID: 70412 Summary: -Wswitch and functions that can only return a small set of values Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: izaberina at gmail dot com Target Milestone: --- $ cat wswitch.c #include <stdio.h> typedef enum { a, b, c, d, e } letter; letter func (int arg) { if (arg > 0) return a; return b; } int main() { switch(func(7)) { case a: puts("a"); break; case b: puts("b"); break; } return 0; } $ gcc -Wall wswitch.c wswitch.c: In function 'main': wswitch.c:11:3: warning: enumeration value 'c' not handled in switch [-Wswitch] switch(func(7)) { ^ wswitch.c:11:3: warning: enumeration value 'd' not handled in switch [-Wswitch] wswitch.c:11:3: warning: enumeration value 'e' not handled in switch [-Wswitch] This is more of a question than a bug report: does that code need a default case? I think it shouldn't, it handles all the possible return values... Is that warning useful? For the records, clang 3.7 reports a very similar warning.