Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/constinit9.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/91360 - Implement C++20 P1143R2: constinit | |
2 // { dg-do run { target c++2a } } | |
3 // A run-time test. | |
4 | |
5 constexpr int foo (int x) { return x; } | |
6 constinit int b = foo(42); | |
7 | |
8 int | |
9 main () | |
10 { | |
11 if (b != 42) | |
12 __builtin_abort (); | |
13 // We can still modify 'b'. | |
14 b = 10; | |
15 if (b != 10) | |
16 __builtin_abort (); | |
17 | |
18 constinit static int s = foo(14); | |
19 if (s != 14) | |
20 __builtin_abort (); | |
21 s++; | |
22 if (s != 15) | |
23 __builtin_abort (); | |
24 } |