| 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 |
Y y; |
| 31 |
std::uninitialized_fill_n(addr, 1, y); |
| 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 |
std::uninitialized_fill_n(addr, 1, 99); |
| 52 |
} |
| 53 |
#endif |