<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107861>107861</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] [C++] Redefinition in hidden friend
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PolarLinda6
</td>
</tr>
</table>
<pre>
```cpp
template<typename>
void func();
template<typename>
struct define_func {
template<typename>
friend void func() {}
};
auto main() -> int {
[[maybe_unused]] define_func<int> _{};
}
```
#### error message:
```txt
<source>:7:15: error: redefinition of 'func'
7 | friend void func() {}
| ^
<source>:11:37: note: in instantiation of template class 'define_func<int>' requested here
11 | [[maybe_unused]] define_func<int> _{};
| ^
<source>:7:15: note: previous definition is here
7 | friend void func() {}
| ^
```
#### Additional Information:
Version: clang version 18.1.8
Link: [godbolt](https://godbolt.org/z/xfM17vcMc)
PS: The code compiles successfully on gcc and msvc.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklN-PozYQx_-a4WW0EdghwAMP-bGRKt1Jp7bq68qxh8Stsaltotv-9ZWB7Oaia7fqIStBZma-3_n4hwhBny1RC-UOykMmxnhxvv3ijPCftFVik52cem1hk89DDgPkB8i3kfrBiEjA9_F1ICt6Av48f7s6rbAbrQRWA2uA7-b5jzND9KOMqKjTll5SCYRqycZ_S0TsvCar8EF7Sq8Oi351ePAixuiwF9ou0U_An1HbeKeKE5pdL15P9DLaMZCC8gDl4d4l8L22MSW_LIJvOm_iN4T3-sD420Dy3nnsKQRxJuDbbwJv2fFrXGb4PrjRy4kB31bAt0UJfDuXSS-eJoc6amfRdQismsFUS2sVQrXH_4QOp2cOv3-gfP6unaIAvuXJFFqXlmyL2qK2IQobtbhZui0pSiNCSA6_BxVYhZ7-HClEUnghT2-mimIx9WOr9N7ePzX0zvfWz-Dpqt0Y8I6yDt_a-3-I3z18uGe2Sk3KwuBPtnO-n9A-bJ7fyId5NnG2Z7zOE1jUq2JVz0GftP0jRUC5Ozt1ciYmgKy-xDiEVJAdgR2XTyvnz8COfwE7fu0-F9VVfpbppN-JfvklVfv1QiidSj_9oA0FDKOUFEI3GvOKzuJZShRWYR-ucrWQyFTLVcMbkVFbVKys63qd8-zSrkXVUVPKkrF1sW7qTtYdVbRhLM9Zo3imW5azdd7kTcHZZs1Wiit5UgUX9UY2JEtY59QLbVbGXPvURqZDGKkt8qreFJkRJzJhug4Zm2ABY-lm9G1KeDqN5wDr3OgQw3uJqKOZ7tA5ozwkintguzTKA-LP90dRW7xopcguuyIbvWkfMOt4GU8r6XpgxySz_D0N3v1OMgI7TrYDsOPi_NqyvwMAAP__FkyqMw">