Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated3.C

raw
1 // P0595R1
2 // { dg-do run { target c++14 } }
3
4 struct false_type { static constexpr bool value = false; };
5 struct true_type { static constexpr bool value = true; };
6 template<class T, class U>
7 struct is_same : false_type {};
8 template<class T>
9 struct is_same<T, T> : true_type {};
10
11 int a[__builtin_is_constant_evaluated () ? 1 : 2];
12 int b[1];
13 static_assert (is_same<decltype (a), decltype (b)>::value, "");
14
15 int
16 main ()
17 {
18 int c[__builtin_is_constant_evaluated () ? 3 : 4];
19 int d[3];
20 static_assert (is_same<decltype (c), decltype (d)>::value, "");
21 int (*e)[7][9] = new int[__builtin_is_constant_evaluated () ? -1 : 5]
22 [__builtin_is_constant_evaluated () ? 7 : 8]
23 [__builtin_is_constant_evaluated () ? 9 : 10];
24 e[0][0][0] = 6;
25 delete[] e;
26 }