[Clang][ItaniumMangle] Lambda mangling does not preserve field-name closure-prefix
Compare the following in clang vs. gcc:
struct E {
template<typename T>
E(T t);
};
template<typename T>
E::E(T t) {
struct{
int anotherValue = [x = 1] { return x; }();
} obj;
}
E e(1);
Reproducer: https://godbolt.org/z/eWGWjoeM1
Mangled symbols:
clang: _ZZN1EC1IiEET_ENKUt_UlvE_clEv
gcc: _ZZN1EC4IiEET_ENKUt_12anotherValueMUlvE_clEv
Clang appears to drop the field-name closure-prefix (12anotherValueM) in the lambda mangling.
clang version 22.1.2 gcc version 15.2.1 20260209 (GCC)
Originally posted by @efriedma-quic in https://github.com/llvm/llvm-project/pull/181068#discussion_r3037281491
@llvm/issue-subscribers-clang-frontend
Author: eiytoq (eiytoq)
struct E {
template<typename T>
E(T t);
};
template<typename T>
E::E(T t) {
struct{
int anotherValue = [x = 1] { return x; }();
} obj;
}
E e(1);
Compile commands:
clang++ -std=c++20 -c test.cpp -o test.clang.o
g++ -std=c++20 -fkeep-inline-functions -c test.cpp -o test.gcc.o
Mangled symbols:
clang: _ZZN1EC1IiEET_ENKUt_UlvE_clEv
gcc: _ZZN1EC4IiEET_ENKUt_12anotherValueMUlvE_clEv
Clang appears to drop the field-name closure-prefix (12anotherValueM) in the lambda mangling.
clang version 22.1.2 gcc version 15.2.1 20260209 (GCC)
Originally posted by @efriedma-quic in https://github.com/llvm/llvm-project/pull/181068#discussion_r3037281491