1 // { dg-do run { target c++11 } }
4 #include <testsuite_hooks.h>
6 // PR libstdc++/108846 std::copy, std::copy_n and std::copy_backward
7 // on potentially overlapping subobjects
10 B(int i
, short j
) : i(i
), j(j
) {}
15 D(int i
, short j
, short x
) : B(i
, j
), x(x
) {}
16 short x
; // Stored in tail padding of B
26 // If this is optimized to memmove it will overwrite tail padding.
27 std::move_backward(src
, src
+1, dst
+1);
29 #if __cpp_lib_ranges >= 201911L
30 std::ranges::move_backward(src
, src
+1, dst
+1);
36 B2(int i
, short j
) : i(i
), j(j
) {}
37 B2
& operator=(B2
&& b
) { i
= b
.i
; j
= b
.j
; return *this; }
42 D2(int i
, short j
, short x
) : B2(i
, j
), x(x
) {}
43 short x
; // Stored in tail padding of B2
53 // Ensure the not-taken trivial copy path works for this type.
54 std::move_backward(src
, src
+1, dst
+1);
56 #if __cpp_lib_ranges >= 201911L
57 std::ranges::move_backward(src
, src
+1, dst
+1);
63 B3(int i
, short j
) : i(i
), j(j
) {}
64 B3
& operator=(B3
&&) = default;
69 D3(int i
, short j
, short x
) : B3(i
, j
), x(x
) {}
70 short x
; // Stored in tail padding of B3
74 test_move_only_trivial()
80 // Ensure the not-taken trivial copy path works for this type.
81 std::move_backward(src
, src
+1, dst
+1);
83 #if __cpp_lib_ranges >= 201911L
84 std::ranges::move_backward(src
, src
+1, dst
+1);
93 test_move_only_trivial();