<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61763>61763</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-16 regression] Friend declaration of a constrained friend class inside of a class template causes compile error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
loskutov
</td>
</tr>
</table>
<pre>
```c++
#include <concepts>
template <class = void>
struct Foo {
template <std::same_as<void> Param>
friend struct Bar;
};
template struct Foo<>;
template <std::same_as<void> Param>
struct Bar {
};
```
Clang-16 and further reject this program with the following error message:
```c++
<source>:11:11: error: type constraint differs in template redeclaration
template <std::same_as<void> Param>
^
<source>:5:15: note: previous template declaration is here
template <std::same_as<void> Param>
^
1 error generated.
Compiler returned: 1
```
Clang versions 11-15 work as expected, though.
Compiler Explorer link: https://godbolt.org/z/erGavP1za.
GCC also had a similar bug at some point: [93467](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93467).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVM2O4ygQfhpyKXVkQ5yfgw_dSXuu8wYjDGWbbQwWBclMP_0Kx-lkWr0r7Y6FMILiq6_qK0oSmd4h1qx6YdVpJVMcfKitp7cU_XnVev2rZsWJFc9sW1yHYvwlj-suF8YpmzQCE0flncIpEhOvy_E8RxwnK-PVxEoiYOIEZ2_0hyHFkFSExntguwUbAODxKkXNxDMTzyRH_CGJieOCAd9lkOMHWL7YBYNOw4L7IgMTN8q70339O787CyaOGe4f7P4LmTuDe2S_Ubjl9dHT0UrXP5VbkE5Dl0IcMEDAv1BFiIMhmILvgxzhYuIAcUDovLX-YlwPGIIPMCKR7DFz_Df5xJF8CgrnYJ_L8jZdUfIi_poQlHcUgzQugjZdh4HAuLs4ATUqK4OMxrs_yBWw6vVLYlXmlSdwPuagYAp4Nj7RncQDBTAEAwZcUP93Ed2_D2Llkt8eHQYZUa8Xxfw4GTurFFNwmL1A-aXEs7hwxkDGO4KyfCoruPjwBpIAf06oImrGjxAHn_rhs4PXn5P1AQNY496ylyHGiXJQvGG86b1uvY1rH3rGm3fGGwzf5Pl7-S7XjyX27XgEacnDIDVIIDMaKwO0qQcZgfyIMHnjYvbAqpeD2Gx3rDoxvv_kT6l179Lir039u7FWMt7Q4C8_2tSvVW-YaHKOT1cUflivdC30QRzkCutyuy-K4rAvq9VQ77oD7tsWxV5wta02JW-7QyG0EFy1bSVXpuYFF4Xg-1JwIap1h50QXGw3ld5LsdmzTYGjNHZt7XnMtFaGKGG9LXdbsbKyRUtzv-Pc4QXmQ8Z5bn-hznee2tQT2xTWUKQ7SjTRzo1S3R5nwD4gZRVZdYLm2nEey9B3IO9vB_WtK12boHFkNC5G885HoSqZCAnUVfNrya1SsPWn3Js4pHat_Mh4k4kuv6cp-NwrGG_m8IjxZg7_7wAAAP__i6DRyQ">