[llvm-bugs] [Bug 46508] New: use of overloaded operator '==' is ambiguous (with reversed parameter order)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 29 23:22:31 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46508
Bug ID: 46508
Summary: use of overloaded operator '==' is ambiguous (with
reversed parameter order)
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: dermojo at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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
--
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/20200630/b6f3d8ad/attachment.html>
More information about the llvm-bugs
mailing list