Although the standard does not make this a mistake (enumerations are integer syntax), this is certainly what the compiler can detect. Clang , compiling with -Wenum-compare , gives:
Bonsai:~ adamw$ clang++ test.cpp test.cpp:15:45: warning: comparison of two values with different enumeration types ('IsOptionAEnum' and 'IsOptionBEnum') [-Wenum-compare] if (optionA == IsOptionA_YES || optionA == IsOptionB_YES)
Perhaps Visual C ++ does not warn about this by default. Try to set a flag /Wall in the compiler, which will include all the warnings. If it still does not warn, you can submit a request with the VC compiler command.
Edit: as other answers and comments were mentioned, if you have VC11, you can use Strongly typed enums .
source share