gcc/testsuite/g++.dg/opt/pr98130.C
raw| 1 | // PR c++/98130 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | // { dg-options "-O2" } |
| 4 | |
| 5 | #include <new> |
| 6 | |
| 7 | typedef int *T; |
| 8 | |
| 9 | static unsigned char storage[sizeof (T)] alignas (T); |
| 10 | static T *p = (T *) storage; |
| 11 | |
| 12 | static inline __attribute__((__always_inline__)) void |
| 13 | foo (T value) |
| 14 | { |
| 15 | new (p) T(value); |
| 16 | } |
| 17 | |
| 18 | int |
| 19 | main () |
| 20 | { |
| 21 | int a; |
| 22 | foo (&a); |
| 23 | if (!*p) |
| 24 | __builtin_abort (); |
| 25 | } |