1 // PR c++/91360 - Implement C++20 P1143R2: constinit 2 // { dg-do run { target c++2a } } 3 // A run-time test. 4 foo(int x)5constexpr int foo (int x) { return x; } 6 constinit int b = foo(42); 7 8 int main()9main () 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 } 25