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
[clang][rejects valid][c++20] bad parse of constrained friend function #83461
Comments
@llvm/issue-subscribers-clang-frontend Author: Eric Niebler (ericniebler)
The following should compile (-std=c++20):
template <class A>
concept always_true = true;
struct receiver {
template <class Tag = int>
friend void tag_invoke( always_true auto, receiver self) {
}
}; All recent versions of clang including trunk rejects this code with:
|
@llvm/issue-subscribers-c-20 Author: Eric Niebler (ericniebler)
The following should compile (-std=c++20):
template <class A>
concept always_true = true;
struct receiver {
template <class Tag = int>
friend void tag_invoke( always_true auto, receiver self) {
}
}; All recent versions of clang including trunk rejects this code with:
|
Confirmed: https://godbolt.org/z/96Y4e4j1r I don't know what is going on here, maybe @erichkeane does |
I've never seen that error before... At least it doesn't have anything to do with concepts (reduced away as:
My guess is that we're somehow ordering the 'auto' parameter 'last' in template argument ordering rather than 'first'. I'm not sure what the CORRECT answer is there though, and wonder if this is either a CWG issue-worthy thing, or just a clang bug (Can anyone find some prose that gives explaination here?). But effectively what it looks like is happening is that our check to prevent this pattern:
Is picking up the 'auto' parameter. |
Side note, we don't seem to have this problem with Lambdas, so figuring out what we do differently there might be informative: https://godbolt.org/z/1WzdWvKK3 |
OH! Strangly it is ONLY in the case of a friend function, free/member function aren't affected either for some reason. |
Ah, figured it out... all my speculation was wrong! Its an incorrect implementation of https://eel.is/c++draft/temp.param#14 WIP now. |
The first sentence says: If a template-parameter of a class template, variable template, or alias template has a default template-argument, each subsequent template-parameter shall either have a default template-argument supplied or be a template parameter pack. However, we were only testing for "not a function function template", and referring to an older version of the standard. As far as I can tell, CWG2032 added the variable-template, and the alias-template pre-dates the standard on github. This patch started as a bug fix for llvm#83461 , but ended up fixing a number of similar cases, so those are validated as well.
The first sentence says: If a template-parameter of a class template, variable template, or alias template has a default template-argument, each subsequent template-parameter shall either have a default template-argument supplied or be a template parameter pack. However, we were only testing for "not a function function template", and referring to an older version of the standard. As far as I can tell, CWG2032 added the variable-template, and the alias-template pre-dates the standard on github. This patch started as a bug fix for #83461 , but ended up fixing a number of similar cases, so those are validated as well.
Thank you for the speedy fix! |
The following should compile (-std=c++20):
All recent versions of clang including trunk rejects this code with:
https://godbolt.org/z/6G1hPsKM3
The text was updated successfully, but these errors were encountered: