gcc/libstdc++-v3/testsuite/23_containers
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
..
array libstdc++: Fix std::to_array for trivial-ish types [PR115522] 2024-07-12 11:12:27 +01:00
deque libstdc++: Replace unnecessary uses of built-ins in testsuite 2024-03-07 20:55:25 +00:00
forward_list libstdc++: Replace unnecessary uses of built-ins in testsuite 2024-03-07 20:55:25 +00:00
headers Update copyright years. 2024-01-03 12:19:35 +01:00
list libstdc++: Replace unnecessary uses of built-ins in testsuite 2024-03-07 20:55:25 +00:00
map libstdc++: Replace unnecessary uses of built-ins in testsuite 2024-03-07 20:55:25 +00:00
multimap Update copyright years. 2024-01-03 12:19:35 +01:00
multiset libstdc++: Destroy allocators in re-inserted container nodes [PR114401] 2024-03-22 22:39:06 +00:00
priority_queue Update copyright years. 2024-01-03 12:19:35 +01:00
queue Update copyright years. 2024-01-03 12:19:35 +01:00
set libstdc++: Destroy allocators in re-inserted container nodes [PR114401] 2024-03-22 22:39:06 +00:00
span Update copyright years. 2024-01-03 12:19:35 +01:00
stack Update copyright years. 2024-01-03 12:19:35 +01:00
unordered_map libstdc++: Replace unnecessary uses of built-ins in testsuite 2024-03-07 20:55:25 +00:00
unordered_multimap Update copyright years. 2024-01-03 12:19:35 +01:00
unordered_multiset libstdc++: Destroy allocators in re-inserted container nodes [PR114401] 2024-03-22 22:39:06 +00:00
unordered_set libstdc++: Destroy allocators in re-inserted container nodes [PR114401] 2024-03-22 22:39:06 +00:00
vector libstdc++: Replace stacktrace effective target with feature test 2024-03-26 11:32:55 +00:00