| 1 |
// PR c++/97388 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
struct S { |
| 5 |
int m; |
| 6 |
constexpr S () : m(1) {} |
| 7 |
constexpr ~S () noexcept (false) { if (m == 1) { throw; } } |
| 8 |
}; |
| 9 |
|
| 10 |
constexpr bool |
| 11 |
foo (S v) |
| 12 |
{ |
| 13 |
v.m = 2; |
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
constexpr bool |
| 18 |
bar () |
| 19 |
{ |
| 20 |
return foo (S ()); |
| 21 |
} |
| 22 |
|
| 23 |
constexpr bool |
| 24 |
baz () |
| 25 |
{ |
| 26 |
foo (S ()); |
| 27 |
return foo (S ()); |
| 28 |
} |
| 29 |
|
| 30 |
static_assert (foo (S ())); |
| 31 |
static_assert (bar ()); |
| 32 |
static_assert (baz ()); |
| 33 |
constexpr bool x = foo (S ()); |
| 34 |
constexpr bool y = bar (); |
| 35 |
constexpr bool z = baz (); |