Debian Codegraph @

libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc

raw
1 // { dg-do compile }
2
3 #include <memory>
4 #include <algorithm>
5
6 struct X;
7
8 struct Y
9 {
10 operator X() const;
11 };
12
13 struct X
14 {
15 private:
16 void operator=(const Y&);
17 };
18
19 Y::operator X() const { return X(); }
20
21 #if __cplusplus >= 201103L
22 static_assert( std::is_trivially_default_constructible<X>::value, "" );
23 static_assert( std::is_trivially_copyable<X>::value, "" );
24 #endif
25
26 void test01_pr102064()
27 {
28 unsigned char buf[sizeof(X)];
29 X* addr = reinterpret_cast<X*>(buf);
30 const Y y[1] = { };
31 std::uninitialized_copy(y, y + 1, addr);
32 }
33
34 #if __cplusplus >= 201103L
35 struct Z
36 {
37 Z() = default;
38 Z(int) { }
39 Z(const Z&) = default;
40 Z& operator=(const Z&) = default;
41 Z& operator=(int) = delete;
42 };
43
44 static_assert( std::is_trivially_default_constructible<Z>::value, "" );
45 static_assert( std::is_trivially_copyable<Z>::value, "" );
46
47 void test02_pr102064()
48 {
49 unsigned char buf[sizeof(Z)];
50 Z* addr = reinterpret_cast<Z*>(buf);
51 const int i[1] = { 99 };
52 std::uninitialized_copy(i, i + 1, addr);
53 }
54 #endif