fork(5) download
  1. extern int const a;
  2.  
  3. struct A {
  4. constexpr A () {}
  5. int x { a };
  6. };
  7.  
  8. int const a = 5;
  9.  
  10. int main () {
  11. static_assert (A {}.x == 5, "!!");
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘constexpr A::A()’:
prog.cpp:4:19: error: the value of ‘a’ is not usable in a constant expression
   constexpr A () {}
                   ^
prog.cpp:1:18: note: ‘a’ was not initialized with a constant expression
 extern int const a;
                  ^
prog.cpp: In function ‘int main()’:
prog.cpp:11:3: error: non-constant condition for static assertion
   static_assert (A {}.x == 5, "!!");
   ^
prog.cpp:11:3: error: ‘constexpr A::A()’ called in a constant expression
stdout
Standard output is empty