gcc/testsuite/g++.dg/cpp2a/consteval-virtual2.C
raw| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | struct A |
| 4 | { |
| 5 | virtual consteval int f() const { return 1; }; |
| 6 | }; |
| 7 | |
| 8 | struct B: A |
| 9 | { |
| 10 | virtual consteval int f() const { return 2; }; |
| 11 | virtual void g() { } |
| 12 | }; |
| 13 | |
| 14 | consteval int f() |
| 15 | { |
| 16 | const A& ar = B(); |
| 17 | return ar.f(); |
| 18 | } |
| 19 | |
| 20 | static_assert (f() == 2); |
| 21 | |
| 22 | B b; |