llvm/llvm-project

[clang] [C++20] Defaulted `operator==` doesn't lookup in using-directive properly

オープン

#97,087 opened on 2024/06/28

 (11 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (10,782 件のフォーク)batch import
clang:frontendgood first issue

Repository metrics

Stars
 (26,378 個のスター)
PR merge metrics
 (平均マージ 1d 2h) (30d で 1,000 merged PRs)

説明

https://godbolt.org/z/c8v65nGzc

struct X {};
namespace NS {
    bool operator==(X, X);
}
using namespace NS;
struct Y {
    X x;
    friend bool operator==(Y, Y);
};
bool operator==(Y, Y) = default;
<source>:10:6: error: defaulting this equality comparison operator would delete it after its first declaration
   10 | bool operator==(Y, Y) = default;
      |      ^
<source>:7:7: note: defaulted 'operator==' is implicitly deleted because there is no viable 'operator==' for member 'x'
    7 |     X x;
      |       ^

If it is defaulted in the class it does compile and properly call NS::operator==(X, X): https://godbolt.org/z/M8Msc8T3a
If the function-body is replaced it also compiles: https://godbolt.org/z/19sEre7KW

コントリビューターガイド