Open
Description
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.
Example:
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.)