[LLVMbugs] [Bug 9735] New: Obj-C++ regression: overloading isn't preferring the conversion-to-superclass over the conversion-to-void*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 15 11:26:41 PDT 2011


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

           Summary: Obj-C++ regression: overloading isn't preferring the
                    conversion-to-superclass over the conversion-to-void*
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Consider:

#import <AppKit/AppKit.h>

#include <iostream>
using namespace std;

template <typename T>
inline void g(std::ostream* os, const T& val) {
 *os << val;
}

std::ostream& operator<<(std::ostream& out, const NSObject* obj) {
 return out << "asdf";
}

void f(ostream& out, const NSEvent* e) {
 g(&out, e);
}


This compiles fine in gcc and used to compile fine in clang before r129339. But
now clang complains:


test.mm:8:7: error: use of overloaded operator '<<' is ambiguous (with operand
types 'std::ostream' (aka 'basic_ostream<char>') and 'const NSEvent *const')
  *os << val;
  ~~~ ^  ~~~
test.mm:16:3: note: in instantiation of function template specialization
'g<const NSEvent *>' requested here
  g(&out, e);
  ^
/usr/include/c++/4.2.1/ostream:228:7: note: candidate function
      operator<<(const void* __p)
      ^
test.mm:11:15: note: candidate function
std::ostream& operator<<(std::ostream& out, const NSObject* obj) {
              ^
/usr/include/c++/4.2.1/ostream:176:7: note: candidate function
      operator<<(bool __n)
      ^
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 llvm-bugs mailing list