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