[Clang, C++20] Undefined symbol for redeclared friend function with requires.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Clang seems not to recognize that a friend function is redeclared, if it has "requires".
```
#include
template
struct A
{
friend constexpr inline void b(A) requires(i == 3)
{}
};
constexpr void b(A<3>);
void Do()
{
::b(A<3>());
}
```
Emits:
```
"Do()":
jmp "b(A<3ul>)"
```
This results in an unresolvable function reference at link time.
GCC seems to behave the same way, however MSVC gets it right.
If the "requires" is removed, everything works fine.
Contributor guide
Research direction
Start by compiling and linking the supplied C++20 reproducer with Clang, then compare it with the version where requires is removed. Trace friend-function redeclaration and symbol generation, and add a regression test once the relevant compiler test area is identified; done means the example links and the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100