| 1 |
// PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr. |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
// dynamic_cast in a destructor. |
| 5 |
|
| 6 |
struct A2 { virtual void a2(); }; |
| 7 |
|
| 8 |
struct A : A2 { virtual void a(); }; |
| 9 |
|
| 10 |
struct C2 { virtual void c2(); }; |
| 11 |
|
| 12 |
struct B : A, C2 { |
| 13 |
constexpr ~B(); |
| 14 |
}; |
| 15 |
|
| 16 |
constexpr B::~B() |
| 17 |
{ |
| 18 |
A *a = dynamic_cast<A*>((C2*)this); |
| 19 |
if (a != (A*) this) |
| 20 |
__builtin_abort (); |
| 21 |
A& ar = dynamic_cast<A&>((C2&)*this); |
| 22 |
if (&ar != &(A&)*this) |
| 23 |
__builtin_abort (); |
| 24 |
} |
| 25 |
|
| 26 |
struct D : B { virtual void d(); }; |
| 27 |
|
| 28 |
constexpr D d; |