-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++20 reversed operator== not properly suppressed by operator!= in namespace #68901
C++20 reversed operator== not properly suppressed by operator!= in namespace #68901
Comments
@llvm/issue-subscribers-clang-frontend Author: James Y Knight (jyknight)
```
namespace N {
struct A {};
bool operator==(A, int);
bool operator!=(A, int);
}
bool a = 0 == N::A();
```
This should fail to compile, because the existence of Moving @usx95 |
@llvm/issue-subscribers-c-20 Author: James Y Knight (jyknight)
```
namespace N {
struct A {};
bool operator==(A, int);
bool operator!=(A, int);
}
bool a = 0 == N::A();
```
This should fail to compile, because the existence of Moving @usx95 |
Same issue but this errors instead: namespace A {
struct Derived {};
struct Base : Derived {};
bool operator==(Derived& a, Base& b);
bool operator!=(Derived& a, Base& b);
} // namespace A
void foo() {
A::Base a, b;
(void)(a == b);
} |
`S.getScopeForContext` determins the **active** scope associated with the given `declContext`. This fails to find the matching `operator!=` if candidate `operator==` was found via ADL since that scope is not active. Instead, just directly lookup using the namespace decl of `operator==` Fixes #68901
/cherry-pick 9330261 |
Failed to cherry-pick: 9330261 https://github.com/llvm/llvm-project/actions/runs/6876823292 Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:
|
) `S.getScopeForContext` determins the **active** scope associated with the given `declContext`. This fails to find the matching `operator!=` if candidate `operator==` was found via ADL since that scope is not active. Instead, just directly lookup using the namespace decl of `operator==` Fixes llvm#68901 (cherry picked from commit 9330261)
/branch usx95/llvm-project/release/17.x |
/pull-request llvm/llvm-project-release-prs#778 |
/branch usx95/llvm-project/release/17.x |
`S.getScopeForContext` determins the **active** scope associated with the given `declContext`. This fails to find the matching `operator!=` if candidate `operator==` was found via ADL since that scope is not active. Instead, just directly lookup using the namespace decl of `operator==` Fixes #68901 (cherry picked from commit 9330261)
) `S.getScopeForContext` determins the **active** scope associated with the given `declContext`. This fails to find the matching `operator!=` if candidate `operator==` was found via ADL since that scope is not active. Instead, just directly lookup using the namespace decl of `operator==` Fixes llvm#68901 (cherry picked from commit 9330261)
This should fail to compile, because the existence of
operator!=
should suppress the reversedoperator==(int, A)
. However, on Clang it does not.Moving
bool a
within the namespace does make it correctly fail to compile, which suggests that name lookup for the operator!= is not being done in the correct scope.@usx95
The text was updated successfully, but these errors were encountered: