summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-07-20 16:51:44 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-07-20 23:38:48 +0100
commit87a9bfe86d8a87d09de5d60e430d14bfa6c816f0 (patch)
tree52a0d2c1898c82e3c8985245dac64c98dd3394fb /libstdc++-v3/testsuite
parent56c999860bbbb2fd5091ba0985e2e5eaa90c6478 (diff)
libstdc++: Fix std::common_iterator triviality [PR100823]
This fixes the remaining problem reported in the PR, that the special members should be trivial. This can be done by constraining the non-trivial versions and adding defaulted overloads that will be used when the union members are trivial. Making these members trivial alters the argument passing ABI and so isn't suitable for backporting to release branches. libstdc++-v3/ChangeLog: PR libstdc++/100823 * include/bits/stl_iterator.h (common_iterator): Define destructor, copy constructor and move constructor as trivial when the underlying types allow. * testsuite/24_iterators/common_iterator/100823.cc: Check triviality of special members.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc b/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc
index 4f2b23de8cc..b42dd087ab2 100644
--- a/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc
+++ b/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc
@@ -5,6 +5,21 @@
#include <testsuite_hooks.h>
void
+test_triviality()
+{
+ using I = std::common_iterator<int*, const int*>;
+
+ // Cannot be trivial, because it has to initialize members.
+ static_assert( ! std::is_trivially_default_constructible_v<I> );
+
+ static_assert( std::is_trivially_destructible_v<I> );
+ static_assert( std::is_trivially_copy_constructible_v<I> );
+ static_assert( std::is_trivially_copy_assignable_v<I> );
+ static_assert( std::is_trivially_move_constructible_v<I> );
+ static_assert( std::is_trivially_move_assignable_v<I> );
+}
+
+void
test_valueless_assignment()
{
int x[1] { };