diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-06-18 13:27:02 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-06-21 10:10:10 +0100 |
commit | 510ce5eed69ee1bea9c2c696fe3b2301e16d1486 (patch) | |
tree | 9f2827ed2836e773ad7a56ed9dfc14ee2ce2a565 /libcpp | |
parent | e2fb245b07f489ed5bfd9a945e0053b4a3211245 (diff) | |
download | gcc-510ce5eed69ee1bea9c2c696fe3b2301e16d1486.zip gcc-510ce5eed69ee1bea9c2c696fe3b2301e16d1486.tar.gz gcc-510ce5eed69ee1bea9c2c696fe3b2301e16d1486.tar.bz2 |
libstdc++: Fix std::to_array for trivial-ish types [PR115522]
Due to PR c++/85723 the std::is_trivial trait is true for types with a
deleted default constructor, so the use of std::is_trivial in
std::to_array is not sufficient to ensure the type can be trivially
default constructed then filled using memcpy.
I also forgot that a type with a deleted assignment operator can still
be trivial, so we also need to check that it's assignable because the
is_constant_evaluated() path can't use memcpy.
Replace the uses of std::is_trivial with std::is_trivially_copyable
(needed for memcpy), std::is_trivially_default_constructible (needed so
that the default construction is valid and does no work) and
std::is_copy_assignable (needed for the constant evaluation case).
libstdc++-v3/ChangeLog:
PR libstdc++/115522
* include/std/array (to_array): Workaround the fact that
std::is_trivial is not sufficient to check that a type is
trivially default constructible and assignable.
* testsuite/23_containers/array/creation/115522.cc: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions