2 // { dg-do run { target c++11 } }
3 // { dg-options "-O0" }
5 void *operator new (decltype (sizeof 0), void *p) noexcept { return p; }
7 struct A { char c; int i; };
8 #if __cplusplus >= 201402L
9 struct B { A a; constexpr B (char x, int y) : a () { a.c = x; a.i = y; } };
11 struct B { A a; B (char x, int y) : a () { a.c = x; a.i = y; } };
17 unsigned char buf[sizeof (B)];
19 __builtin_memcpy (buf, &a1, sizeof (buf));
22 unsigned char m1 alignas (A) [sizeof (A)];
23 __builtin_memset (m1, -1, sizeof (m1));
24 A *a2 = new (m1) A ();
25 __builtin_memcpy (buf, a2, sizeof (*a2));
29 __builtin_memcpy (buf, &b1, sizeof (b1));
32 unsigned char m2 alignas (B) [sizeof (B)];
33 B *b2 = new (m2) B (1, 2);
34 __builtin_memcpy (buf, b2, sizeof (*b2));
37 #if __cplusplus >= 201402L
38 constexpr B b3 (3, 4);
39 __builtin_memcpy (buf, &b3, sizeof (b3));
46 bar (unsigned char *p)
54 unsigned char buf[256];
55 __builtin_memset (buf, -1, sizeof (buf));
62 if (__builtin_offsetof (A, c) == 0
63 && __builtin_offsetof (A, i) != 1
64 && __builtin_offsetof (B, a) == 0
65 && sizeof (A) == sizeof (B))