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

           Summary: Poor diagnostic for conditional expression with
                    mismatched types
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


>From a Clang user at Google:
"""
#include <cstddef>
class A {};
int main(int argc, char** argv) {
 A a;
 bool b = true;
 A* foo = b ? a : NULL;
 return 0;
}

The bug here is that I meant to write "&a", not "a".  The error that
shows up is:

foo.cc:6:14: error: incompatible operand
types ('A' and 'long')

I was confused at first, because what did I write there that has
anything to do with numbers?  Of course I quickly did realize that
NULL is just 0 and thus a long.

Thought: If you have incompatible operands for the second and third
arguments to the ternary operator, and exactly one of them matches the
surrounding context (as NULL matches the "A* foo =") and the other
doesn't, perhaps the error should point out the incompatibility
between the other argument and the surrounding context rather than
between the two terms?
"""

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to