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
7int r;
8void *p;
9
10struct VBase
11{
12  virtual void f () {}
13  VBase() { p = this; }
14  ~VBase() { if (p != this) r = 1; }
15};
16
17struct  StreamBase
18{
19  virtual ~StreamBase() {}
20};
21
22struct  Stream : public virtual VBase, public StreamBase
23{
24  Stream() {}
25  virtual ~Stream() {}
26};
27
28struct DerivedStream : public Stream
29{
30  DerivedStream() { throw 1; }
31};
32
33int main() {
34
35  try
36    {
37      DerivedStream str;
38    }
39  catch (...) { }
40
41  return r;
42}
43