1 // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr.
2 // { dg-do compile { target c++20 } }
3 
4 // Ambiguous base.
5 
6 struct A { virtual void a(); };
7 struct B : A { virtual void b(); };
8 struct C : A { virtual void c(); };
9 struct D { virtual void a(); };
10 struct E : B, C, D { virtual void d(); };
11 
12 constexpr E e;
13 
14 constexpr bool b1 = (dynamic_cast<A&>((D&)e), false); // { dg-error "reference .dynamic_cast. failed" }
15 // { dg-message ".A. is an ambiguous base class of dynamic type .E. of its operand" "" { target *-*-* } .-1 }
16 
17 static_assert (dynamic_cast<A*>((D*)&e) == nullptr);
18