#include <iostream> using namespace std; struct Foo { int member; Foo() = default; }; int main() { const Foo foo; cout << foo.member << endl; }
Standard input is empty
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; ^~~~~~
Standard output is empty