Given: int main(void) { enum foo { A, B, C, D} bar; bar = D; if(bar == A) { ; } else if(bar == B) { ; } else { switch(bar) { case C: case D: ; } } return 0; } barbeque/zarathustra:src: /usr/local/bin/gcc-4.1.0 -Wswitch-enum a.c a.c: In function 'main': a.c:10: warning: enumeration value 'A' not handled in switch a.c:10: warning: enumeration value 'B' not handled in switch A & B aren't valid targets for the switch statement by the time it's hit as they have been handled by the if statements above. Locally built gcc: barbeque/zarathustra:src: /usr/local/bin/gcc-4.1.0 -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.1.0/configure --prefix=/usr/local/stow/gcc-4.1.0 --enable-languages=c,c++,objc --infodir=/usr/local/stow/gcc-4.1.0/share/info --mandir=/usr/local/stow/gcc-4.1.0/share/man --enable-shared --enable-threads --enable-tls --program-suffix=-4.1.0 --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-targets=x86_64-unknown-linux-gnu --enable-bootstrap=lean --disable-biarch --disable-multilib Thread model: posix gcc version 4.1.0 On Debian/stable from amd64.debian.net. Also happens on gcc 3.3.5 from the Debian apt archives.
Confirmed. But this is unlikely to be fixed as it would require moving the diagnostic to the middle-end where this information is available. And diagosticts from the middle-end are notoriously frowned upon.
*** This bug has been marked as a duplicate of 23577 ***