Issue |
143218
|
Summary |
Wrong linkage and mangling for class-scope lambda expressions
|
Labels |
new issue
|
Assignees |
|
Reporter |
zygoloid
|
C++ allows lambdas to be defined directly in class scope. When this happens, the lambda should have the same linkage as the class, as it would if it appeared in a default argument or default member initializer or function body within the class, and it should be mangled [with the enclosing class as the mangling context](https://github.com/itanium-cxx-abi/cxx-abi/issues/165).
Example:
```c++
template <auto L> struct B {};
struct A { B<[] { return 0; }> b; };
void f(decltype(A::b) x) {}
```
This should result in an external linkage symbol for `f` being emitted. But Clang incorrectly gives the lambda internal linkage and a mangling involving `$_3`, resulting in no definition for `f` being emitted.
GCC appears to have implemented this in version 15 onwards. (In version 14 and before, GCC used internal linkage for the lambda, as Clang does.)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs