https://gcc.gnu.org/g:d0d3d4dde0b4712a3c39970ec8dcfe0782434d3e
commit r16-7937-gd0d3d4dde0b4712a3c39970ec8dcfe0782434d3e Author: Patrick Palka <[email protected]> Date: Fri Mar 6 17:59:11 2026 -0500 c++: ICE mangling C auto... tparm [PR124297] After r16-7491, the constraint on a C auto... tparm is represented as a fold-expression (in TEMPLATE_PARM_CONSTRAINTS) instead of a concept-id (in PLACEHOLDER_TYPE_CONSTRAINTS). So we now need to strip this fold-expression before calling write_type_constraint, like we do in the type template parameter case a few lines below. PR c++/124297 gcc/cp/ChangeLog: * mangle.cc (write_template_param_decl) <case PARM_DECL>: Strip fold-expression before calling write_type_constraint. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-variadic4.C: New test. Reviewed-by: Jason Merrill <[email protected]> Diff: --- gcc/cp/mangle.cc | 5 +++++ gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index 75d8c6badd66..3b8b9ed9d77b 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -1927,6 +1927,11 @@ write_template_param_decl (tree parm) ? TEMPLATE_PARM_CONSTRAINTS (parm) : NULL_TREE)) { + if (TREE_CODE (c) == UNARY_LEFT_FOLD_EXPR) + { + c = FOLD_EXPR_PACK (c); + c = PACK_EXPANSION_PATTERN (c); + } if (AUTO_IS_DECLTYPE (type)) write_string ("DK"); else diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C new file mode 100644 index 000000000000..f6f4cbfde122 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C @@ -0,0 +1,12 @@ +// PR c++/124297 +// { dg-do compile { target c++20 } } + +template<class T> concept C = true; + +template<C auto... Vs> void f(); + +int main() { + f<42>(); +} + +// { dg-final { scan-assembler "_Z1fITpTnDk1CJLi42EEEvv" } }
