This code:
enum : unsigned { foo = 4 };
enum : unsigned { bar = 32 };
int main() { return bar > foo; }
gives me the following warning (with GCC 5.4.0):
$ g++ --std=c++11 -o a a.cpp
a.cpp: In function ‘int main()’:
a.cpp:4:27: warning: comparison between ‘enum<anonymous>’ and ‘enum<anonymous>’ [-Wenum-compare]
int main() { return bar > foo; }
^
Why is that? I've specified exactly which types these enum values have, there's nothing indeterminate about comparing them. I've even used the same type for both enums (not that it should matter). So what's the deal here?
Note that clang (3.8.0) doesn't produce this warning, even with -Wall
.