OSDN Git Service

PR c++/53549
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / eh / ctor2.C
1 // PR c++/4460
2 // Test that the cleanup for fully-constructed subobjects when a
3 // constructor throws gets the right address for a virtual base.
4
5 // { dg-do run }
6
7 int r;
8 void *p;
9
10 struct VBase
11 {
12   virtual void f () {}
13   VBase() { p = this; }
14   ~VBase() { if (p != this) r = 1; }
15 };
16
17 struct  StreamBase 
18 {
19   virtual ~StreamBase() {}
20 };
21
22 struct  Stream : public virtual VBase, public StreamBase
23 {
24   Stream() {}
25   virtual ~Stream() {} 
26 };
27
28 struct DerivedStream : public Stream
29 {
30   DerivedStream() { throw 1; }
31 };
32
33 int main() {
34
35   try
36     { 
37       DerivedStream str;
38     }
39   catch (...) { }
40
41   return r;
42 }