[LLVMbugs] [Bug 13018] New: Overloaded operators not in the overload set, if argument-type is strongly-typed-enum

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jun 3 11:37:16 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13018

             Bug #: 13018
           Summary: Overloaded operators not in the overload set, if
                    argument-type is strongly-typed-enum
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: lunow at math.hu-berlin.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8674
  --> http://llvm.org/bugs/attachment.cgi?id=8674
Code that does not compile, but sould

The following Code triggers the Bug:

enum class Foo { val };

struct Bar { Bar(Foo) {} };

Bar operator ~(Bar b) { return b; }
Bar operator |(Bar b, Bar) { return b; }

Bar b = ~Foo::val;
Bar c = Foo::val | Foo::val;

int main()
{
  return 0;
}

C:\dev\mingw32_clang\bin>clang.exe ..\..\projects\chess\clang_test.cpp
-std=c++11 -fsyntax-only
..\..\projects\chess\clang_test.cpp:9:9: error: invalid argument type 'Foo' to
unary expression
Bar b = ~Foo::val;
        ^~~~~~~~~
..\..\projects\chess\clang_test.cpp:10:18: error: invalid operands to binary
expression ('Foo' and 'Foo')
Bar c = Foo::val | Foo::val;
        ~~~~~~~~ ^ ~~~~~~~~
2 errors generated.

The expected behaviour is that the correspondig user-defined global operator
functions are called and the parameters be implcititly converted to type Foo.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list