gcc/testsuite/g++.dg/cpp2a/consteval-prop5.C
raw| 1 | // P2564R3 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | consteval int f (int i) { return i; } |
| 5 | |
| 6 | struct S { |
| 7 | int x = f(42); |
| 8 | }; |
| 9 | |
| 10 | constexpr S |
| 11 | immediate (auto) |
| 12 | { |
| 13 | return S{}; |
| 14 | } |
| 15 | |
| 16 | void |
| 17 | g () |
| 18 | { |
| 19 | immediate (0); |
| 20 | } |
| 21 | |
| 22 | consteval void |
| 23 | test () |
| 24 | { |
| 25 | constexpr S s = immediate(0); |
| 26 | static_assert(s.x == 42); |
| 27 | } |