Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-dtor9.C

raw
1 // PR c++/97790
2 // { dg-do compile { target c++20 } }
3
4 struct S
5 {
6 int *d;
7 int n;
8 constexpr S () : d(new int[1]{}), n(1) {}
9 constexpr ~S () { delete [] d; }
10 };
11
12 constexpr S
13 foo ()
14 {
15 return S ();
16 }
17
18 constexpr int
19 bar ()
20 {
21 return foo ().n;
22 }
23
24 constexpr int
25 baz ()
26 {
27 return S ().n;
28 }
29
30 constexpr int a = baz ();
31 constexpr int b = bar ();