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