-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
Bugzilla Link | 46508 |
Version | 10.0 |
OS | Linux |
CC | @rbock,@zygoloid |
Extended Description
Hi,
The following code is a very reduced example from a template expression library:
class Foo {};
class X {
public:
template <typename T>
constexpr Foo operator==(const T&) const
{
return Foo{};
}
};
class A : public X {};
class B : public X {};
int main() {
Foo f = A{} == B{};
return 0;
}
It fails to compile with C++20:
clang++-10 -c sample.cpp -std=c++20
sample.cpp:16:16: error: use of overloaded operator '==' is ambiguous (with operand types 'A' and 'B')
Foo f = A{} == B{};
~~~ ^ ~~~
sample.cpp:6:18: note: candidate function [with T = B]
constexpr Foo operator==(const T&) const
^
sample.cpp:6:18: note: candidate function (with reversed parameter order) [with T = A]
1 error generated.
I can't figure out why the reversed operator is used here (tbh, I'm not a language lawyer).
Any help is appreciated, thanks!
clang++-10 --version
clang version 10.0.0-4ubuntu1~18.04.1
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Type
Projects
Status
Done