https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121231
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:0a7eae02dea519403669ffb1b754f998ce7cf56f commit r16-3046-g0a7eae02dea519403669ffb1b754f998ce7cf56f Author: Patrick Palka <ppa...@redhat.com> Date: Wed Aug 6 09:41:01 2025 -0400 c++: mangling cNTTP object w/ implicit non-trailing zeros [PR121231] Here the results of A::make(0, 0, 1), (0, 1, 0) and (1, 0, 0) are each represented as a single-element CONSTRUCTOR with CONSTRUCTOR_NO_CLEARING cleared, and when used as as a class NTTP argument we end up mangling them all as A{1}, i.e. eliding both the implicit initial and trailing zeros. Mangling them all the same seems clearly wrong since they're logically different values. It turns out the mangling also omits intermediate zeros, e.g. A::make(1, 0, 1) is mangled as A{1, 1}, the same as A::make(1, 1, 0). It seems we can't omit both trailing and non-trailing implicit zeros without introducing mangling ambiguities. This patch makes us include non-trailing zeros in these manglings (while continuing to omit trailing zeros). This also manifests as a wrong-code bug where the specializations table would conflate different specializations that are in terms of different class NTTP arguments, since the identity of such arguments is tied to their mangling. PR c++/121231 PR c++/119688 PR c++/94511 gcc/ChangeLog: * common.opt: Document additional ABI version 21 change. * doc/invoke.texi: Likewise. gcc/cp/ChangeLog: * mangle.cc (write_expression): Write out implicit non-trailing zeroes of a CONSTRUCTOR when the ABI version is at least 21. gcc/testsuite/ChangeLog: * g++.dg/abi/mangle82.C: New test. * g++.dg/cpp2a/nontype-class73.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com>