<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107175>107175</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++23] Redefinition in special cases
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PolarLinda6
</td>
</tr>
</table>
<pre>
```cpp
#include <print>
template<typename>
struct define_f {
friend void f() {}
};
template<auto = [] {}>
struct A {};
struct B {
template<typename T>
consteval void func() {
[[maybe_unused]] define_f<T> _{};
}
} obj;
auto main() -> int {
obj.func<decltype(A{})>();
std::print(" ");
}
```
#### error message:
```txt
<source>:5:15: error: redefinition of 'f'
5 | friend void f() {}
| ^
<source>:14:34: note: in instantiation of template class 'define_f<A<(lambda at <source>:8:17){}>>' requested here
14 | [[maybe_unused]] define_f<T> _{};
| ^
<source>:19:7: note: in instantiation of function template specialization 'B::func<A<(lambda at <source>:8:17){}>>' requested here
19 | obj.func<decltype(A{})>();
| ^
<source>:5:15: note: previous definition is here
5 | friend void f() {}
|
```
#### Additional Information:
Version: clang version 18.1.8
compilation parameter: -std=c++23
Link: [godbolt](https://godbolt.org/z/bzKT1ae7K)
PS: The code compiles successfully on gcc and msvc.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU9v47YT_TTjyyCGRFqRddBBttfAD7uHxa9BrwFFjW2mFKmSlNHk0xfUH0cxNthiW0OgCc5w5r3HR0l4r86GqIRsB9lhJfpwsa78brVw35RpxOOqts1rCY_J-Miug-QASQWMKyN13xAC33dOmQD8yxQbxkBtp0Ug4Pvw2pERLd0yfHC9DNjQSRl6PiHkuzGAeHKKTINXqxo8AdsCK4ZwfpiK5wfgu08aiT5YBH7Akc-88a5tdVv_UGeK7hZofsABn27lEKU1PtBV6Alvb-QC8pSEI5pdK15reu5N76mB7BDxzQIA38ey-HwHDHHJG239cod5INwKZaa2D7G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