This compiles perfectly fine with the current MSVC compiler:
struct Foo
{
} const foo;
However, it fails to compile with the current g++ compiler:
error: uninitialized const 'foo' [-fpermissive]
note: 'const struct Foo' has no user-provided default constructor
If I provide a default constructor myself, it works:
struct Foo
{
Foo() {}
} const foo;
Is this another case of MSVC being too permissive, or is g++ too strict here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…