Issue 107861
Summary [clang] [C++] Redefinition in hidden friend
Labels clang
Assignees
Reporter PolarLinda6
    ```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.
 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to