[LLVMbugs] [Bug 16682] New: rvalue overload hides the const lvalue one?

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 23 06:31:56 PDT 2013


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

            Bug ID: 16682
           Summary: rvalue overload hides the const lvalue one?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: marc.glisse at normalesup.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

struct A{};
struct B{operator const A()const;};
void f(A const&);
#ifdef ERR
void f(A&&);
#endif
int main(){
  B a;
  f(a);
}

Compiled with clang++ -std=c++11, it is happy. If I add -DERR, clang++
complains:

l.cc:9:5: error: no viable conversion from 'B' to 'A'
  f(a);
    ^
l.cc:1:8: note: candidate constructor (the implicit copy constructor) not
      viable: no known conversion from 'B' to 'const A &' for 1st argument
struct A{};
       ^
l.cc:1:8: note: candidate constructor (the implicit move constructor) not
      viable: no known conversion from 'B' to 'A &&' for 1st argument
struct A{};
       ^
l.cc:2:10: note: candidate function
struct B{operator const A()const;};
         ^
l.cc:5:11: note: passing argument to parameter here
void f(A&&);
          ^
1 error generated.

The error message is not very helpful, and g++ accepts the code. This happens
quite easily with the standard library (list::push_front for instance).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130723/e5b41994/attachment.html>


More information about the llvm-bugs mailing list