Debian Codegraph @

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

raw
1 // PR c++/104568
2 // { dg-do compile { target c++20 } }
3 // { dg-options "" }
4
5 struct S { int s; constexpr S () : s (0) {} constexpr ~S () {} };
6 typedef int T[0];
7 typedef int U[0];
8
9 constexpr bool
10 foo ()
11 {
12 auto p = new T[2];
13 auto q1 = &p[0];
14 auto q2 = &p[1];
15 auto q3 = &p[2];
16 delete[] p;
17 return true;
18 }
19
20 constexpr bool
21 bar ()
22 {
23 auto p = new U[2];
24 auto q1 = &p[0];
25 auto q2 = &p[1];
26 auto q3 = &p[2];
27 delete[] p;
28 return true;
29 }
30
31 constexpr bool
32 baz ()
33 {
34 auto p = new T[0];
35 auto q1 = &p[0];
36 delete[] p;
37 return true;
38 }
39
40 constexpr bool a = foo ();
41 constexpr bool b = bar ();
42 constexpr bool c = baz ();