https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124487
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Make that
--- gcc/cp/mangle.cc.jj 2026-03-09 10:05:44.653968731 +0100
+++ gcc/cp/mangle.cc 2026-03-13 16:26:50.820006547 +0100
@@ -2744,9 +2744,10 @@ write_type (tree type)
break;
case PACK_INDEX_TYPE:
- /* TODO Mangle pack indexing
- <https://github.com/itanium-cxx-abi/cxx-abi/issues/175>. */
- sorry ("mangling type pack index");
+ /* https://github.com/itanium-cxx-abi/cxx-abi/issues/175 */
+ write_string ("Dy");
+ write_type (PACK_EXPANSION_PATTERN (PACK_INDEX_PACK (type)));
+ write_expression (PACK_INDEX_INDEX (type));
break;
case LANG_TYPE:
@@ -3602,6 +3603,14 @@ write_expression (tree expr)
else
goto normal_expr;
}
+ else if (code == PACK_INDEX_EXPR)
+ {
+ /* https://github.com/itanium-cxx-abi/cxx-abi/issues/175
+ sy rather than sysp. */
+ write_string ("sy");
+ write_expression (PACK_EXPANSION_PATTERN (TREE_OPERAND (expr, 0)));
+ write_expression (TREE_OPERAND (expr, 1));
+ }
else if (TREE_CODE (expr) == ALIGNOF_EXPR)
{
if (!ALIGNOF_EXPR_STD_P (expr))
otherwise we mangle DyDp, which doesn't match what the clang patch does.
That said, given that it isn't in clang trunk and I don't want to bother
compiling their patch, I've just tried their
https://github.com/cor3ntin/llvm-project/blob/f17310f2c62a17f937aa90444b7087f0b5696606/clang/test/CodeGenCXX/mangle-cxx2c.cpp
testcase f to check for compatibility.
The 2 bar calls are mangled the same between GCC with the above patch and their
patch,
baz obviously diverges (they have some _SUBSTPACK_ in there), and foo diverges
too,
clang patch vs. gcc:
_ZN8GH1120033fooILi0ETpTnDaJLi0ELi0EEEEDTsyT0_T_Ev
_ZN8GH1120033fooILi0EJLi0ELi0EEEEDtsyT0_T_Ev
There is extra TpTnDa in their mangling, but that doesn't seem to be related to
pack indexing I think.