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 {
fVBase12   virtual void f () {}
VBaseVBase13   VBase() { p = this; }
~VBaseVBase14   ~VBase() { if (p != this) r = 1; }
15 };
16 
17 struct  StreamBase
18 {
~StreamBaseStreamBase19   virtual ~StreamBase() {}
20 };
21 
22 struct  Stream : public virtual VBase, public StreamBase
23 {
StreamStream24   Stream() {}
~StreamStream25   virtual ~Stream() {}
26 };
27 
28 struct DerivedStream : public Stream
29 {
DerivedStreamDerivedStream30   DerivedStream() { throw 1; }
31 };
32 
main()33 int main() {
34 
35   try
36     {
37       DerivedStream str;
38     }
39   catch (...) { }
40 
41   return r;
42 }
43