Open dwblaikie opened 1 year ago
The ABI already mostly covers this: we require a lambda to be numbered within the scope of the enclosing variable if the variable is inline or a variable template, but we missed the case where it's a non-inline static data member, eg:
template<typename T> int print_hello = (std::cout << "hello\n", 0);
struct X {
// Should only print hello once, regardless of how many TUs this appears in.
static const intptr_t n = (print_hello<decltype([]{})>, 0);
};
I've updated #85 to cover that case too.
Clang fails and emits these with local linkage and non-standard mangling (if they are actually internal, that'd be fine) GCC emits these names without using the member name in the mangling and a numbering that's not local to the member, or even local to the type (similar names in subsequent classes get numberings that differ depending on the previous class - despite the class name in the mangling) https://godbolt.org/z/7514cTh5o
GCC produces these manglings:
Clang produces these manglings:
I think both GCC and Clang gets C right, Clang gets B right (& GCC gets it wrong) and both Clang and GCC get A wrong for different reasons. (and it should be like Clang's B behavior).
This is discussed in Clang (https://github.com/llvm/llvm-project/issues/58819) and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107741)