On trunk (also seen in gcc-4.4.0), gcc doesn't compile this snippet: ======================================== enum class E { A }; bool foo() { return E::A == E::A; } ========================================
in C++0x mode (cc1plus -quiet -std=c++0x enumtest.cpp -o /tmp/enumtest.s), giving this error: ---------------------------------------- enumtest.cpp: In function 'bool foo()': enumtest.cpp:2: error: invalid operands of types 'E' and 'E' to binary 'operator==' ---------------------------------------- I think this snippet is valid, since my interpretation of N2857's [over.built]/15: For every T, where T is an enumeration type or pointer to effective object type, there exist candidate operator functions of the form bool operator<(T , T ); bool operator>(T , T ); bool operator<=(T , T ); bool operator>=(T , T ); bool operator==(T , T ); bool operator!=(T , T ); is that type E should have a built-in operator==. This is confirmed by the expected error message when compiling this snippet: ======================================== enum class E { A }; enum class F { B }; bool foo() { return E::A == F::B; } ======================================== which is: ---------------------------------------- enumtest2.cpp: In function 'bool foo()': enumtest2.cpp:3: error: no match for 'operator==' in '(E)0 == (F)0' enumtest2.cpp:3: note: candidates are: operator==(F, F) <built-in> enumtest2.cpp:3: note: operator==(E, E) <built-in> enumtest2.cpp:3: note: operator==(int, int) <built-in> ---------------------------------------- This message says there is indeed a built-in 'operator==(E, E)'. Shouldn't it be found when compiling the first snippet? This creates failures in Boost regression tests for runners using gcc-4.4.0 in C++0x mode (as scoped enums have been enabled on that configuration recently). -- Summary: No built-in comparison operators for scoped enums (C++0x) Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: frabar666 at gmail dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40193