| 1 |
// { dg-do run } |
| 2 |
// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org> |
| 3 |
// DR193: Order of destruction of local automatics of destructor |
| 4 |
|
| 5 |
extern "C" void abort(void); |
| 6 |
|
| 7 |
namespace N1 { |
| 8 |
bool a_done = false; |
| 9 |
struct A |
| 10 |
{ |
| 11 |
~A() |
| 12 |
{ |
| 13 |
a_done = true; |
| 14 |
} |
| 15 |
}; |
| 16 |
|
| 17 |
struct B |
| 18 |
{ |
| 19 |
~B() |
| 20 |
{ |
| 21 |
if (!a_done) |
| 22 |
abort(); |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
struct C { |
| 27 |
B x; |
| 28 |
~C() { |
| 29 |
A y; |
| 30 |
} |
| 31 |
}; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
namespace N2 { |
| 36 |
bool a_done = false; |
| 37 |
|
| 38 |
template <class> |
| 39 |
struct A |
| 40 |
{ |
| 41 |
~A() |
| 42 |
{ |
| 43 |
a_done = true; |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
template <class> |
| 48 |
struct B |
| 49 |
{ |
| 50 |
~B() |
| 51 |
{ |
| 52 |
if (!a_done) |
| 53 |
abort(); |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
template <class T> |
| 58 |
struct C { |
| 59 |
B<T> x; |
| 60 |
~C() { |
| 61 |
A<T> y; |
| 62 |
} |
| 63 |
}; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
int main(void) |
| 68 |
{ |
| 69 |
N1::C c1; |
| 70 |
N2::C<void> c2; |
| 71 |
return 0; |
| 72 |
} |