inconsistent warnings for bitfield based enumernations in switch statement with g++
Issue
- When I compile the code attached I get the following error:
- Here's the compiler output:
../enum_test.cpp: In function 'void enum_test(STATE, sm_multi_state*, lg_multi_state*)':
../enum_test.cpp:21: error: enumeration value 'MAX' not handled in switch
../enum_test.cpp:27: error: case value '5' not in enumerated type 'STATE'
../enum_test.cpp:39: error: enumeration value 'MAX' not handled in switch
../enum_test.cpp:45: error: case value '5' not in enumerated type 'STATE'
-
We would expect the same two errors as seen on lines 21/27 and 39/45 to be flagged for lines 30/36 as well for the switch on sm_state->state1, but we don't get them.
-
I am using the following command to compile the attached code:
/usr/bin/g++ -c -Wswitch enum_test.cpp
- Could you let me know if this is the result of a compiler problem. The error does not appear to be consistent.
Environment
- Red Hat Enterprise Linux 6.4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.