Issue |
129778
|
Summary |
Lambdas as non‐type template parameters cause link errors (.rodata._ZTAXtl3$_0EE defined in discarded section)
|
Labels |
new issue
|
Assignees |
|
Reporter |
ryanofsky
|
I am encountering a linker error with Clang 19.1.4 when using lambdas as non‐type template parameters across multiple translation units. The minimal example below compiles without issues using GCC and also _does not_ trigger the link error in Clang when optimizations (`-O`) are enabled or if I change the parameter from `const auto&` to `auto` (i.e., pass by value rather than by const reference).
Error:
```c++
`.rodata._ZTAXtl3$_0EE' referenced in section `.text' of pass_b.o: defined in discarded section `.rodata._ZTAXtl3$_0EE[_ZTAXtl3$_0EE]' of pass_b.o
```
(`_ZTAXtl3$_0EE` demangles to `template parameter object for $_0{}`.)
Command to reproduce:
```bash
clang++ -std=c++20 pass_a.cpp pass_b.cpp
```
Example code:
__pass.h__
```c++
#ifndef PASS_H
#define PASS_H
void PassArg(const auto& arg)
{
}
template<auto object>
void PassTemplate()
{
PassArg(object);
}
#endif
```
__pass_a.cpp__
```c++
#include "pass.h"
constexpr auto fn_a = []{};
void pass_a()
{
PassTemplate<fn_a>();
}
int main(int, char**)
{
return 0;
}
```
__pass_b.cpp__
```c++
#include "pass.h"
constexpr auto fn_b = []{};
void pass_b()
{
PassTemplate<fn_b>();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs