Issue 71595
Summary [17 regression][C++20] templated friend not working if the concept use contains the enclosing friend
Labels clang:frontend, regression
Assignees
Reporter 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>
 friend void unwindStack();

    UnwindFrame();
};

template <Test<UnwindFrame> F>
void unwindStack()
{
    auto u = UnwindFrame();
}

int main()
{
 unwindStack<int>();
}
```
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:
```
<source>:16:14: error: calling a private constructor of class 'UnwindFrame'
   16 |     auto u = UnwindFrame();
      | ^
<source>:21:5: note: in instantiation of function template specialization 'unwindStack<int>' requested here
   21 | unwindStack<int>();
      |     ^
<source>:10:5: note: implicitly declared private here
   10 |     UnwindFrame();
      | ^
```
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 class `UnwindFrame` in this case. 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to