| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
consteval int id (int i) { return i; } |
| 4 |
consteval int add (int i, int j) { return i + j; } |
| 5 |
|
| 6 |
constexpr int |
| 7 |
foo (int i = id (42)) |
| 8 |
{ |
| 9 |
return i + id (id (id (0))); |
| 10 |
} |
| 11 |
|
| 12 |
constexpr int |
| 13 |
bar (int i = id (id (id (42)))) |
| 14 |
{ |
| 15 |
return i; |
| 16 |
} |
| 17 |
|
| 18 |
constexpr int |
| 19 |
baz (int i = add (add (id (1), id (2)), id (3))) |
| 20 |
{ |
| 21 |
return i; |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
g () |
| 26 |
{ |
| 27 |
foo (); |
| 28 |
bar (); |
| 29 |
baz (); |
| 30 |
} |
| 31 |
|
| 32 |
static_assert (foo () == 42); |
| 33 |
static_assert (bar () == 42); |
| 34 |
static_assert (baz () == 6); |