gcc/testsuite/g++.dg/pr109524.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-require-effective-target c++11 } |
| 3 | // { dg-options "-O3 -fno-tree-forwprop -fnon-call-exceptions -fno-tree-ccp -fno-tree-fre" } |
| 4 | |
| 5 | struct nn; |
| 6 | void f(); |
| 7 | int *m; |
| 8 | struct _Guard { |
| 9 | ~_Guard() { |
| 10 | if (_M_guarded) |
| 11 | __builtin_unreachable(); |
| 12 | } |
| 13 | nn *_M_guarded; |
| 14 | }; |
| 15 | struct nn { |
| 16 | int * _M_dataplus; |
| 17 | nn(const nn &) |
| 18 | { |
| 19 | f(); |
| 20 | _Guard __guard; |
| 21 | m = _M_dataplus; |
| 22 | } |
| 23 | nn(){} |
| 24 | }; |
| 25 | void hnn(nn *a) |
| 26 | { |
| 27 | f(); |
| 28 | _Guard __guard; |
| 29 | m = a->_M_dataplus; |
| 30 | } |
| 31 | bool gg(); |
| 32 | static inline nn |
| 33 | hh(nn str) { |
| 34 | if (gg()) |
| 35 | return str; |
| 36 | __builtin_unreachable(); |
| 37 | } |
| 38 | void h() { |
| 39 | |
| 40 | hh({}); |
| 41 | } |