Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-typeid4.C

raw
1 // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr.
2 // { dg-do compile { target c++17 } }
3 // Test typeid in a template.
4
5 #include <typeinfo>
6
7 struct B { virtual void f(); };
8 struct B2 : B { };
9
10 template<typename T>
11 constexpr bool
12 fn ()
13 {
14 constexpr B2 b2;
15 static_assert(&typeid(b2) == &typeid(B2)); // { dg-error ".typeid. is not a constant expression because .b2. is of polymorphic type|non-constant condition" "" { target c++17_down } }
16 return true;
17 }
18
19 static_assert (fn<int>());