fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Foo {
  5. int member;
  6. Foo() = default;
  7. };
  8.  
  9. int main() {
  10. const Foo foo;
  11.  
  12. cout << foo.member << endl;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:10:12: error: uninitialized const ‘foo’ [-fpermissive]
  const Foo foo;
            ^~~
prog.cpp:4:8: note: ‘const struct Foo’ has no user-provided default constructor
 struct Foo {
        ^~~
prog.cpp:6:2: note: constructor is not user-provided because it is explicitly defaulted in the class body
  Foo() = default;
  ^~~
prog.cpp:5:6: note: and the implicitly-defined constructor does not initialize ‘int Foo::member’
  int member;
      ^~~~~~
stdout
Standard output is empty