<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63536>63536</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-16 regression in friend functions with concept-constrained template arguments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DeadlyRedCube
</td>
</tr>
</table>
<pre>
godbolt link: https://godbolt.org/z/j86T8dzMY
In clang 16 (tested in both 16.0.0 via godbolt and 16.0.6 via the standard llvm Ubuntu distro), if you friend a function with a template argument that is concept-constrained:
```
template <typename T> concept some_concept = true;
template <some_concept T>
class Foo
{
private:
Foo();
template <some_concept U> friend Foo<U> Friended(U a);
};
template <some_concept T>
Foo<T> Friended(T a)
{ return {}; }
void Bar()
{ Friended(1); }
```
it fails to compile with a spurious error:
```
<source>:13:12: error: calling a private constructor of class 'Foo<int>'
{ return {}; }
^
<source>:16:5: note: in instantiation of function template specialization 'Friended<int>' requested here
{ Friended(1); }
^
<source>:7:3: note: declared private here
Foo();
^
```
If the function uses `typename` instead of `some_concept` it compiles fine (the supplied godbolt link has both versions)
This compiles fine in clangs 14 and 15 (as well as gcc and msvc).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v4zYQ_TX0ZRBDIm1ZOujgxGtgD70UzqGngiLHFrc0qfLDQfLrC1KSo02zQBYwZInkvHnz9ci9VxeD2JLtI9keVjyG3rr2gFzq1z9RPsUOV52Vr-3Fys7qAFqZfwjbQx_C4AnbE3ok9Djtrq27EHp8I_T4o65OtXz74y9SHEixH5_fDQjNzQXKCgitA_qAEpSBzoYeympdrAu4KQ6zN27kuFzl5dAj-MCN5E6C1rcrPHfRhAhS-eAsoQ2hT6DO8GojnJ1CI4HDORoRlDXwokIPHAJeB80DAneXeEUTIPQ8gPIgrBE4hAdhjQ-OK4MyhbiIgFTF9MufdyjCnsLrgIZfE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