[LLVMbugs] [Bug 9993] New: Enum with explicit enum-base is not	promoted to int
    bugzilla-daemon at llvm.org 
    bugzilla-daemon at llvm.org
       
    Mon May 23 12:49:14 PDT 2011
    
    
  
http://llvm.org/bugs/show_bug.cgi?id=9993
           Summary: Enum with explicit enum-base is not promoted to int
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
The following program fails to compile with clang r131897:
//enum e: unsigned int {      // (A)
enum e: unsigned short {  // (B)
    A,
    B,
    C
};
int main(int, char**)
{
    e    a = A;
    return a > 0;
}
The error message is: "use of overloaded operator '>' is ambiguous (with
operand types 'e' and 'int')"
As integral promotions can promote "a" to both "unsigned short" (the enum-base)
and "int" (the promoted enum-base), the latter being the type of the "0" that
"a" is being compared with, this code should compile (and return false/0).
When line (A) is replaced by line (B), the code compiles.
On cfe-dev, Johannes Schaub posted another program that fails to compile as
well (<http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-May/015220.html>):
enum e : unsigned short { };
void f(int); // should take this
void f(long);
int main() {
 e e1;
 f(e1);
}
In this case, the error message is: "call to 'f' is ambiguous".
-- 
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