You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'
}
The text was updated successfully, but these errors were encountered:
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.
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.
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
transferred this issue from llvm/llvm-bugzilla-archive
Dec 3, 2021
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'
}
The text was updated successfully, but these errors were encountered: