gcc/testsuite/g++.old-deja/g++.other/dtor10.C
raw| 1 | // { dg-do run } |
| 2 | // Origin: Mark Mitchell <[email protected]> |
| 3 | |
| 4 | extern "C" void abort (); |
| 5 | |
| 6 | int j; |
| 7 | |
| 8 | struct S { |
| 9 | static S* s[5]; |
| 10 | |
| 11 | S () { s[j++] = this; } |
| 12 | S (const S&) { s[j++] = this; } |
| 13 | ~S () { |
| 14 | for (int k = 0; k < j; ++k) |
| 15 | if (s[k] == this) |
| 16 | return; |
| 17 | abort (); |
| 18 | } |
| 19 | }; |
| 20 | |
| 21 | S* S::s[5]; |
| 22 | |
| 23 | struct T { |
| 24 | int i; |
| 25 | S s; |
| 26 | }; |
| 27 | |
| 28 | T t; |
| 29 | |
| 30 | T f () { |
| 31 | return t; |
| 32 | } |
| 33 | |
| 34 | void g (S) { |
| 35 | } |
| 36 | |
| 37 | int main () |
| 38 | { |
| 39 | g (f ().s); |
| 40 | } |
| 41 |