]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: mangling of array new [PR119316]
authorJason Merrill <jason@redhat.com>
Wed, 19 Mar 2025 09:15:00 +0000 (05:15 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 19 Mar 2025 21:58:23 +0000 (17:58 -0400)
commit80e1dac3849b134ebd5e0151e9c9e4b8b091de72
tree37343b646cff006767d99761f6905ad26a919d62
parente3b3290f7330a81176d3d5d7c77623cd6c4bc70c
c++: mangling of array new [PR119316]

Because we build an array type to represent an array new, we hit a VLA
error in compute_array_index_type for a variable length array new.  To avoid
this, let's build the MINUS_EXPR and index type directly.

I also noticed that the non-constant case in write_array_type was assuming
MINUS_EXPR without verifying it, so I added a checking_assert.

I also noticed that Clang doesn't mangle the length of an array new at all,
so I opened https://github.com/itanium-cxx-abi/cxx-abi/issues/199 to clarify
this.

PR c++/119316

gcc/cp/ChangeLog:

* mangle.cc (write_expression) [NEW_EXPR]: Avoid using
compute_array_index_type.
(write_array_type): Add checking_assert.

gcc/testsuite/ChangeLog:

* g++.dg/abi/mangle-new1.C: New test.
gcc/cp/mangle.cc
gcc/testsuite/g++.dg/abi/mangle-new1.C [new file with mode: 0644]