-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[17 regression][C++20] templated friend not working if the concept use contains the enclosing class #71595
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: Markus Böck (zero9178)
Recently upgraded to Clang 17 which lead to code that previously worked in Clang 16 to suddently stop compiling. I have reduced it to the following snippet:
```cpp
template <class T, class U>
concept Test = true;
class UnwindFrame
}; template <Test<UnwindFrame> F> int main()
<source>:16:14: error: calling a private constructor of class 'UnwindFrame'
|
@llvm/issue-subscribers-c-20 Author: Markus Böck (zero9178)
Recently upgraded to Clang 17 which lead to code that previously worked in Clang 16 to suddently stop compiling. I have reduced it to the following snippet:
```cpp
template <class T, class U>
concept Test = true;
class UnwindFrame
}; template <Test<UnwindFrame> F> int main()
<source>:16:14: error: calling a private constructor of class 'UnwindFrame'
|
I recently ran into a similar issue:
Gives
Please let me know if this is similar enough to also be discussed in this issue, or if I should open a new one. |
I believe the issue is with checking if the constraint uses any enclosing template parameters for [temp.friend]p9. If a containing record is used as argument, we assume that the constraint depends on enclosing template parameters without checking if the record is a template. In the above reproducers I'm not the most well versed with the standard though, so I'd appreciate if someone more experienced can give their input before I send a patch for this. |
…rs to containing template arguments (#74265) When checking if the constraint uses any enclosing template parameters for [temp.friend]p9, if a containing record is used as argument, we assume that the constraint depends on enclosing template parameters without checking if the record is templated. The reproducer from the bug is included as a test case. Fixes #71595
Recently upgraded to Clang 17 which lead to code that previously worked in Clang 16 to suddently stop compiling. I have reduced it to the following snippet:
https://godbolt.org/z/1vcqeGnG1
When using Clang 17 or newer the
friend
declaration seemingly has no effect causing a compilation failure due to the use of a private constructor:This used to work in Clang 16 and is valid C++20 I believe.
While reducing, I noticed the following important properties for this to be reproducible:
unwindStack
HAS to be restricted by a concept and the concept HAS to be templated, with a template parameter being the enclosing classUnwindFrame
in this case.The text was updated successfully, but these errors were encountered: