public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40193]  New: No built-in comparison operators for scoped enums (C++0x)
@ 2009-05-18 21:58 frabar666 at gmail dot com
  2009-05-18 22:12 ` [Bug c++/40193] " paolo dot carlini at oracle dot com
  0 siblings, 1 reply; 2+ messages in thread
From: frabar666 at gmail dot com @ 2009-05-18 21:58 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/40193] No built-in comparison operators for scoped enums (C++0x)
  2009-05-18 21:58 [Bug c++/40193] New: No built-in comparison operators for scoped enums (C++0x) frabar666 at gmail dot com
@ 2009-05-18 22:12 ` paolo dot carlini at oracle dot com
  0 siblings, 0 replies; 2+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-05-18 22:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2009-05-18 22:12 -------


*** This bug has been marked as a duplicate of 38064 ***


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40193


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-18 22:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-18 21:58 [Bug c++/40193] New: No built-in comparison operators for scoped enums (C++0x) frabar666 at gmail dot com
2009-05-18 22:12 ` [Bug c++/40193] " paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).