Debian Codegraph @

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

raw
1 // PR c++/93310
2 // { dg-do compile { target c++20 } }
3
4 struct A
5 {
6 virtual constexpr char f () const
7 { return 'A'; }
8 };
9
10 struct B : A
11 {
12 char x;
13
14 constexpr B () : x (0)
15 { x = ((A *)this)->f(); }
16
17 virtual constexpr char f () const
18 { return 'B'; }
19 };
20
21 struct C : B
22 {
23 virtual constexpr char f () const
24 { return 'C'; }
25 };
26
27 constexpr C c;
28 static_assert (c.x == 'B');