gcc/libstdc++-v3/testsuite/23_containers/array
Jonathan Wakely 21c8708ba6 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.

(cherry picked from commit 510ce5eed69ee1bea9c2c696fe3b2301e16d1486)
2024-07-12 11:12:27 +01:00
..
capacity Update copyright years. 2024-01-03 12:19:35 +01:00
comparison_operators Update copyright years. 2024-01-03 12:19:35 +01:00
cons Update copyright years. 2024-01-03 12:19:35 +01:00
creation libstdc++: Fix std::to_array for trivial-ish types [PR115522] 2024-07-12 11:12:27 +01:00
debug Update copyright years. 2024-01-03 12:19:35 +01:00
element_access Update copyright years. 2024-01-03 12:19:35 +01:00
iterators Update copyright years. 2024-01-03 12:19:35 +01:00
requirements Update copyright years. 2024-01-03 12:19:35 +01:00
specialized_algorithms Update copyright years. 2024-01-03 12:19:35 +01:00
tuple_interface Update copyright years. 2024-01-03 12:19:35 +01:00
range_access.cc Update copyright years. 2024-01-03 12:19:35 +01:00