[LLVMbugs] [Bug 7319] New: Clang rejects enum compare gcc doesn't and prints insane candidate list

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 8 15:39:18 CDT 2010


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

           Summary: Clang rejects enum compare gcc doesn't and prints
                    insane candidate list
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


On this code:

---
#include <iostream>

typedef enum {
Enum1,
Enum2,
Enum3
} MyEnum;

template<typename X>
bool operator>(const X &inX1, const X &inX2)
{
return inX2 < inX1;
}

int main (int argc, const char * argv[]) {

MyEnum e1, e2;

if (e1 > e2)
std::cout << "its larger!\n" << std::endl;
else
std::cout << "its smaller!\n" << std::endl;


std::cout << "Done!\n" << std::endl;
return 0;
}
 ---

GCC accepts this code but clang rejects it.  Clang also does it in a
particularly horrible way, producing:

t.cc:19:8: error: use of overloaded operator '>' is ambiguous
if (e1 > e2)
    ~~ ^ ~~
t.cc:10:6: note: candidate function [with X = MyEnum]
bool operator>(const X &inX1, const X &inX2)
     ^
t.cc:19:8: note: built-in candidate operator>(MyEnum, MyEnum)
if (e1 > e2)
       ^
t.cc:19:8: note: built-in candidate operator>(int, int)
t.cc:19:8: note: built-in candidate operator>(double, int)
t.cc:19:8: note: built-in candidate operator>(unsigned int, int)
t.cc:19:8: note: built-in candidate operator>(unsigned long, int)
t.cc:19:8: note: built-in candidate operator>(long double, int)
t.cc:19:8: note: built-in candidate operator>(long long, int)
t.cc:19:8: note: built-in candidate operator>(float, int)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, int)
t.cc:19:8: note: built-in candidate operator>(long, int)
t.cc:19:8: note: built-in candidate operator>(int, long)
t.cc:19:8: note: built-in candidate operator>(int, long long)
t.cc:19:8: note: built-in candidate operator>(int, unsigned int)
t.cc:19:8: note: built-in candidate operator>(int, unsigned long)
t.cc:19:8: note: built-in candidate operator>(int, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(int, float)
t.cc:19:8: note: built-in candidate operator>(int, double)
t.cc:19:8: note: built-in candidate operator>(int, long double)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, double)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, long double)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, float)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, unsigned long
long)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, unsigned
long)
t.cc:19:8: note: built-in candidate operator>(float, long)
t.cc:19:8: note: built-in candidate operator>(float, long long)
t.cc:19:8: note: built-in candidate operator>(float, unsigned int)
t.cc:19:8: note: built-in candidate operator>(float, unsigned long)
t.cc:19:8: note: built-in candidate operator>(float, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(float, float)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, unsigned int)
t.cc:19:8: note: built-in candidate operator>(float, double)
t.cc:19:8: note: built-in candidate operator>(long double, long double)
t.cc:19:8: note: built-in candidate operator>(long double, double)
t.cc:19:8: note: built-in candidate operator>(long double, float)
t.cc:19:8: note: built-in candidate operator>(long double, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(long double, unsigned long)
t.cc:19:8: note: built-in candidate operator>(long double, unsigned int)
t.cc:19:8: note: built-in candidate operator>(long double, long long)
t.cc:19:8: note: built-in candidate operator>(long double, long)
t.cc:19:8: note: built-in candidate operator>(double, long double)
t.cc:19:8: note: built-in candidate operator>(double, double)
t.cc:19:8: note: built-in candidate operator>(double, float)
t.cc:19:8: note: built-in candidate operator>(double, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(double, unsigned long)
t.cc:19:8: note: built-in candidate operator>(double, unsigned int)
t.cc:19:8: note: built-in candidate operator>(double, long long)
t.cc:19:8: note: built-in candidate operator>(double, long)
t.cc:19:8: note: built-in candidate operator>(float, long double)
t.cc:19:8: note: built-in candidate operator>(unsigned int, long)
t.cc:19:8: note: built-in candidate operator>(long long, long double)
t.cc:19:8: note: built-in candidate operator>(long long, double)
t.cc:19:8: note: built-in candidate operator>(long long, float)
t.cc:19:8: note: built-in candidate operator>(long long, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(long long, unsigned long)
t.cc:19:8: note: built-in candidate operator>(long long, unsigned int)
t.cc:19:8: note: built-in candidate operator>(long long, long long)
t.cc:19:8: note: built-in candidate operator>(long long, long)
t.cc:19:8: note: built-in candidate operator>(long, long double)
t.cc:19:8: note: built-in candidate operator>(long, double)
t.cc:19:8: note: built-in candidate operator>(long, float)
t.cc:19:8: note: built-in candidate operator>(long, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(long, unsigned long)
t.cc:19:8: note: built-in candidate operator>(long, unsigned int)
t.cc:19:8: note: built-in candidate operator>(long, long long)
t.cc:19:8: note: built-in candidate operator>(long, long)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, long long)
t.cc:19:8: note: built-in candidate operator>(unsigned long long, long)
t.cc:19:8: note: built-in candidate operator>(unsigned long, long double)
t.cc:19:8: note: built-in candidate operator>(unsigned long, double)
t.cc:19:8: note: built-in candidate operator>(unsigned long, float)
t.cc:19:8: note: built-in candidate operator>(unsigned long, unsigned long
long)
t.cc:19:8: note: built-in candidate operator>(unsigned long, unsigned long)
t.cc:19:8: note: built-in candidate operator>(unsigned long, unsigned int)
t.cc:19:8: note: built-in candidate operator>(unsigned long, long long)
t.cc:19:8: note: built-in candidate operator>(unsigned long, long)
t.cc:19:8: note: built-in candidate operator>(unsigned int, long double)
t.cc:19:8: note: built-in candidate operator>(unsigned int, double)
t.cc:19:8: note: built-in candidate operator>(unsigned int, float)
t.cc:19:8: note: built-in candidate operator>(unsigned int, unsigned long long)
t.cc:19:8: note: built-in candidate operator>(unsigned int, unsigned long)
t.cc:19:8: note: built-in candidate operator>(unsigned int, unsigned int)
t.cc:19:8: note: built-in candidate operator>(unsigned int, long long)
1 error generated.

-- 
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 LLVMbugs mailing list