]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: new-expr clobber of constant-size array
authorJason Merrill <jason@redhat.com>
Sat, 4 Oct 2025 08:24:29 +0000 (09:24 +0100)
committerJason Merrill <jason@redhat.com>
Tue, 7 Oct 2025 18:34:54 +0000 (19:34 +0100)
commitf4b60fe6d6a16f54347af476e88d534f3666ea08
tree238e2c73ed6908246603f542e50a8b2328b0e86b
parent8b5d577caa32145b24acb948117f628a044028be
c++: new-expr clobber of constant-size array

I previously tried to clobber an array as a whole, but fell back on a loop
due to issues with std::construct_at following the resolution of LWG3436.
But the loop seems to make life hard for the optimizers and it occurs to me
that for a one-element array we can just clobber the element type.

This also fixes some xfails in Warray-bounds-20.C.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber a constant-bound array as a whole.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-20.C: Remove xfails, add diags.
gcc/cp/init.cc
gcc/testsuite/g++.dg/warn/Warray-bounds-20.C