| 1 |
// I think this dynamic_cast has undefined behavior when destroying E::o |
| 2 |
// because we're the F period of destruction has started and ap doesn't |
| 3 |
// point to the object currently being destroyed--but the reasonable |
| 4 |
// options are success or failure, not SEGV. |
| 5 |
|
| 6 |
// { dg-do run } |
| 7 |
|
| 8 |
extern "C" void abort(); |
| 9 |
|
| 10 |
struct A { virtual ~A(); }; |
| 11 |
struct B { virtual ~B() { } }; |
| 12 |
struct C : B, A { }; |
| 13 |
struct E : virtual B { A o; }; |
| 14 |
struct F : virtual C, virtual E { }; |
| 15 |
|
| 16 |
A* ap; |
| 17 |
C* cp; |
| 18 |
|
| 19 |
A::~A() { |
| 20 |
C* cp2 = dynamic_cast<C*>(ap); |
| 21 |
if (cp2 != cp && cp2 != 0) |
| 22 |
abort(); |
| 23 |
} |
| 24 |
|
| 25 |
int main() { |
| 26 |
F f; |
| 27 |
ap = cp = &f; |
| 28 |
} |