-
Notifications
You must be signed in to change notification settings - Fork 13.3k
incorrect overload resolution with deducing this #74494
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
Comments
@llvm/issue-subscribers-clang-frontend Author: None (Tsche)
Hey,
@Waffl3x mentioned a possible bug in clang earlier and asked me to report it.
template<typename T>
concept AlwaysTrue = true;
struct S {
int f(AlwaysTrue auto) { return 1; }; // f1
int f(this S&&, auto) { return 2; }; // f2
};
int main() {
return S{}.f(0);
} https://clang.godbolt.org/z/x516PWsvd According to [[basic.scope.scope]/3](https://eel.is/c++draft/basic.scope.scope#3) |
I believe this is cwg2789: Overload Resolution with implicit and explicit object member functions which is not available yet but should be soon. I believe clang is wrong here. |
https://cplusplus.github.io/CWG/issues/2789.html No, that isn't relevant here, the bullet being changed refers to non-template functions, these are templates. |
There was a bug in Clang where it couldn't choose which overload candidate was more specialized if it was comparing a member-function to a non-member function. Previously, this was detected as an ambiguity, now Clang chooses correctly. This patch fixes the bug by fully implementing CWG2445 and moving the template transformation described in `[temp.func.order]` paragraph 3 from `isAtLeastAsSpecializedAs()` to `Sema::getMoreSpecializedTemplate()` so we have the transformed parameter list during the whole comparison. Also, to be able to add the correct type for the implicit object parameter `Sema::getMoreSpecializedTemplate()` has new parameters for the object type. Fixes #74494, fixes #82509
…#83279) There was a bug in Clang where it couldn't choose which overload candidate was more specialized if it was comparing a member-function to a non-member function. Previously, this was detected as an ambiguity, now Clang chooses correctly. This patch fixes the bug by fully implementing CWG2445 and moving the template transformation described in `[temp.func.order]` paragraph 3 from `isAtLeastAsSpecializedAs()` to `Sema::getMoreSpecializedTemplate()` so we have the transformed parameter list during the whole comparison. Also, to be able to add the correct type for the implicit object parameter `Sema::getMoreSpecializedTemplate()` has new parameters for the object type. Fixes llvm#74494, fixes llvm#82509
Hey,
@Waffl3x mentioned a possible bug in clang earlier and asked me to report it.
https://clang.godbolt.org/z/x516PWsvd
According to [basic.scope.scope]/3
f1
andf2
should have corresponding signatures. Considering [over.match.funcs.general]/5 I believef1
should be called here since it is more constrained. Clang however callsf2
.The text was updated successfully, but these errors were encountered: