]> git.ipfire.org Git - thirdparty/gcc.git/commit
Avoid default-initializing auto_vec<T, N> storage, fix vec<vl_embed>
authorRichard Biener <rguenther@suse.de>
Thu, 23 Feb 2023 10:56:17 +0000 (11:56 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 24 Feb 2023 15:41:36 +0000 (16:41 +0100)
commit2dd68cddbc745de2c4a4b4982673122716c8231c
tree2264d105a68d042dfa84ef637878e489323fcbe6
parentef22c3e90b5010a5229e70907ad2087f774fdfc0
Avoid default-initializing auto_vec<T, N> storage, fix vec<vl_embed>

The following avoids default-initializing auto_vec storage for
non-POD T since that's not what the allocated storage fallback
will do and it's also not expected for existing cases like

  auto_vec<std::pair<unsigned, unsigned>, 64> elts;

which exist to optimize the allocation.

It also fixes the array accesses done by vec<vl_embed> to not
use its own m_vecdata member but instead access the container
provided storage via pointer arithmetic.

* vec.h (vec<T, A, vl_embed>::m_vecdata): Remove.
(vec<T, A, vl_embed>::m_vecpfx): Align as T to avoid
changing alignment of vec<T, A, vl_embed> and simplifying
address.
(vec<T, A, vl_embed>::address): Compute as this + 1.
(vec<T, A, vl_embed>::embedded_size): Use sizeof the
vector instead of the offset of the m_vecdata member.
(auto_vec<T, N>::m_data): Turn storage into
uninitialized unsigned char.
(auto_vec<T, N>::auto_vec): Allow allocation of one
stack member.  Initialize m_vec in a special way to
avoid later stringop overflow diagnostics.
* vec.cc (test_auto_alias): New.
(vec_cc_tests): Call it.
gcc/vec.cc
gcc/vec.h