[LLVMbugs] [Bug 9236] New: Poor diagnostic for conditional expression with mismatched types

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 16 14:45:57 PST 2011


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: unassignedclangbugs at nondot.org
        ReportedBy: matthewbg at google.com
                CC: llvmbugs at cs.uiuc.edu


>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.



More information about the llvm-bugs mailing list