[clang] [clang] Handle templated operators with reversed arguments (PR #69595)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 20 01:46:41 PDT 2023
================
@@ -37,6 +37,25 @@ These changes are ones which we think may surprise users when upgrading to
Clang |release| because of the opportunity they pose for disruption to existing
code bases.
+- Fix a bug in reversed argument for templated operators.
+ This breaks code in C++20 which was previously accepted in C++17. Eg:
+
+ .. code-block:: cpp
+
+ struct P {};
+ template<class S> bool operator==(const P&, const S&);
+
+ struct A : public P {};
+ struct B : public P {};
+
+ bool ambiguous(A a, B b) { return a == b; } // This equality is now ambiguous in C++20.
+
+ template<class S> bool operator!=(const P&, const S&);
+ bool fine(A a, B b) { return a == b; } // Ok. Found a matching operator!=.
+
+ To reduce widespread breakages, as an extension, clang would accept this with a
----------------
ilya-biryukov wrote:
NIT: s/clang/Clang to match the rest of the document.
https://github.com/llvm/llvm-project/pull/69595
More information about the cfe-commits
mailing list