gcc/testsuite/g++.dg/cpp0x/initlist-nrv1.C
raw| 1 | // PR c++/101442 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | bool destroyed = false; |
| 5 | |
| 6 | struct A |
| 7 | { |
| 8 | A() {} |
| 9 | A(const A &) = delete; |
| 10 | A &operator=(const A &) = delete; |
| 11 | ~A() {destroyed = true;} |
| 12 | }; |
| 13 | |
| 14 | struct B |
| 15 | { |
| 16 | const A &a; |
| 17 | struct string { |
| 18 | string(const char*) { } |
| 19 | ~string() { } |
| 20 | } s; |
| 21 | }; |
| 22 | |
| 23 | B foo() |
| 24 | { |
| 25 | B ret{ A{}, "" }; |
| 26 | return ret; |
| 27 | } |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | B b = foo(); |
| 32 | if (!destroyed) |
| 33 | __builtin_abort(); |
| 34 | } |