[LLVMbugs] [Bug 12194] New: incorrect overload resolution result on C++11 container push_*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 6 00:16:58 PST 2012


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

             Bug #: 12194
           Summary: incorrect overload resolution result on C++11
                    container push_*
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Overload resolution selects a non-const&& parameter over a const& parameter for
a const argument:

struct X {};
struct L {
  void push(const X &);
  void push(X &&);
};
struct Y { operator const X() const; };

void f(L l) {
  Y y;
  l.push(y);
}

This gives:

/home/richardsmith/tmp.cpp:10:10: error: no viable conversion from 'Y' to 'X'
  l.push(y);
         ^
/home/richardsmith/tmp.cpp:1:8: note: candidate constructor (the implicit copy
      constructor) not viable: no known conversion from 'Y' to 'const X &' for
      1st argument;
struct X {};
       ^
/home/richardsmith/tmp.cpp:1:8: note: candidate constructor (the implicit move
      constructor) not viable: no known conversion from 'Y' to 'X &&' for 1st
      argument;
struct X {};
       ^
/home/richardsmith/tmp.cpp:6:12: note: candidate function
struct Y { operator const X() const; };
           ^
/home/richardsmith/tmp.cpp:4:17: note: passing argument to parameter here
  void push(X &&);
                ^

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