Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang cannot find a conversion in c++0x mode #11375

Closed
llvmbot opened this issue Sep 24, 2011 · 4 comments
Closed

clang cannot find a conversion in c++0x mode #11375

llvmbot opened this issue Sep 24, 2011 · 4 comments
Labels
bugzilla Issues migrated from bugzilla c++11

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 24, 2011

Bugzilla Link 11003
Resolution FIXED
Resolved on Oct 04, 2011 19:18
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic

Extended Description

gcc can compile the following code in c++ 98 and 0x modes. clang only in 98:

class Value {
};
struct MoveRef {
operator Value &() const ;
};
MoveRef Move(int);
void growTo() {
Value x = Move(0);
Value y(Move(0)); // no viable conversion from 'MoveRef' to 'Value'
}

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 25, 2011

Debugging this and reading the spec it looks like the problem is:

  • clang is trying to initialize a rvalue reference (isLValueRef is false in TryReferenceInitialization).
  • the conversion rule that ends up failing is:

has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be
implicitly converted to an xvalue, class prvalue, or function lvalue of type “cv3 T3”, where
“cv1 T1” is reference-compatible with “cv3 T3

since we have a conversion to a non function lvalue.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 26, 2011

In other words, I think this is a gcc bug, but it would be nice for someone with more c++ experience to take a look.

@efriedma-quic
Copy link
Collaborator

Hmm... I think clang is messing up here: it's somehow picking the Value(Value&&) constructor, but realizes it isn't viable when it actually tries to perform the conversion in question.

@DougGregor
Copy link
Contributor

Hmm... I think clang is messing up here: it's somehow picking the
Value(Value&&) constructor, but realizes it isn't viable when it actually tries
to perform the conversion in question.

Eli is correct. We shouldn't have allowed the binding to the rvalue reference in the first place. Fixed in Clang r141137.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++11
Projects
None yet
Development

No branches or pull requests

3 participants