Issue |
147177
|
Summary |
Cannot declare friend function template with unqualified name in C++20 mode without prior forward declaration
|
Labels |
new issue
|
Assignees |
|
Reporter |
Fedr
|
This program
```c++
template <typename T>
class A {
friend void f<>(A);
};
template <typename T>
void f(A<T>) {}
int main() {
f(A<int>{});
}
```
is accepted in GCC and MSVC starting from C++20. But Clang keeps complaining:
```
error: no candidate function template was found for dependent friend function template specialization
3 | friend void f<>(A);
| ^
```
Online demo: https://gcc.godbolt.org/z/vKjhY9WMv
It looks related to ADL changes for function templates lookup with explicitly-specified template arguments in C++20: https://en.cppreference.com/w/cpp/language/adl.html#Notes
GCC and MSVC both allow unqualified names in template friend declaration `friend void f<>(A&);`, which is accepted if function template `f` is declared after class `A` body but before its instantiation.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs