<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83608>83608</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang doesn't recognise friendship in default parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjdb
</td>
</tr>
</table>
<pre>
This code doesn't compile on Compiler Explorer. Moving the defaulted parameter to the constructor body seems to be okay.
```cpp
template<class T>
class single;
template<class T, class U>
class check_constructible {
check_constructible() = default;
static_assert(is_constructible_v<T, U>);
template<class X>
friend class single;
};
template<class T>
struct single {
template<class U>
single(U u, check_constructible<T, U> = {})
: x(u)
{}
T x;
};
int main() {
single<int> x(0);
}
```
Diagnostic:
```
<source>:25:45: error: calling a private constructor of class 'check_constructible<int, int>'
25 | single(U u, check_constructible<T, U> = {})
| ^
<source>:14:5: note: implicitly declared private here
14 | check_constructible() = default;
| ^
```
Compiler info:
```
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 5b058709536dd883980722ee000bb7b8c7b2cd8b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk-20240301/bin
Compiler returned: 0
```
Both GCC and MSVC accept this code. If it's not conforming, should we accept it as an extension?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU2PozgQ_TXOpZTIsSHAgUOadFZzmNP2rPbWMqYATzs2sk1P-t-vTCDdncnOaqSVIuLP53qvnsvCe9UZxJKkDyQ9rMQYeutK-b2pV7Vt3sqnXnmQtkFoLHpDWBZA2tOgNII1UF2aDh7Pg7YO3Qa-2ldlOgg9QoOtGHXABgbhxAkDOgh2mpLW-OBGGayDeBB4xJOPszWCfRFvG0IPhO7n745efnIYLiMBT4MWAQmvpBbewxPhj5epS98r02kk_OEjzp1drIJL89sNgOxRvjxf41S1RiDZDAcA9xYQ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