| 1 |
// PR tree-optimization/108253 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-O2" } |
| 4 |
|
| 5 |
struct S |
| 6 |
{ |
| 7 |
int *s; |
| 8 |
S () : s (new int) {} |
| 9 |
S (const S &r) noexcept : s (r.s) { __atomic_fetch_add (r.s, 1, 4); } |
| 10 |
}; |
| 11 |
struct T |
| 12 |
{ |
| 13 |
explicit T (const S &x) : t (x) {} |
| 14 |
const S t; |
| 15 |
}; |
| 16 |
struct U |
| 17 |
{ |
| 18 |
operator int () const { new T (u); return 0; } |
| 19 |
S u; |
| 20 |
}; |
| 21 |
bool foo (int matcher); |
| 22 |
unsigned long bar (unsigned long pos, unsigned long end_pos); |
| 23 |
struct V |
| 24 |
{ |
| 25 |
alignas (4) char v[4]; |
| 26 |
}; |
| 27 |
struct W |
| 28 |
{ |
| 29 |
void baz () |
| 30 |
{ |
| 31 |
if (!w) __builtin_abort (); |
| 32 |
if (reinterpret_cast <__UINTPTR_TYPE__> (w->v) % 4 != 0) __builtin_abort (); |
| 33 |
__builtin_unreachable (); |
| 34 |
} |
| 35 |
[[gnu::noinline]] void qux (unsigned long) { if (!w) bar (0, x); } |
| 36 |
V *w = nullptr; |
| 37 |
unsigned x = 0; |
| 38 |
}; |
| 39 |
|
| 40 |
void |
| 41 |
test () |
| 42 |
{ |
| 43 |
W w; |
| 44 |
U t; |
| 45 |
if (!foo (t)) |
| 46 |
w.baz (); |
| 47 |
w.qux (0); |
| 48 |
} |