为什么这个格式错误的程序在 g++ 中编译得很好?

Why this ill formed program compiles fine in g++?

我在 here 上阅读了有关 C++ 中的默认初始化 的内容。它说:

If T is a const-qualified type, it must be a class type with a user-provided default constructor.

link 给出的示例是(我只显示了与我的问题相关的程序语句,其他我省略了):

struct T1 {};
int main()
{
    const T1 nd;    //  error: const class type with implicit ctor
}

但它在 gcc 4.8.1 和 4.9.2 上编译良好。我还使用 -std=c++14 选项编译了它,但它仍然可以正常编译。这是 gcc 扩展还是其他?

因此,我认为上述程序编译成功的原因是struct T1 中没有成员。因此,在这种情况下,此处不会发生默认初始化。但是,如果我添加一个数据成员,例如:

struct T1 { int a; };
int main()
{
    const T1 nd;    //  error: const class type with implicit ctor
}

然后编译器给出相应的错误信息如下:

6 11 [Error] uninitialized const 'a' [-fpermissive]
2 8 [Note] 'const struct T1' has no user-provided default constructor
3 8 [Note] and the implicitly-defined constructor does not initialize 'int T1::a'

那么,语句不应该这样写吗?

If T is a const-qualified type having at least one data member, it must be a class type with a user-provided default constructor.

如果我错了并且理解不正确,请纠正我。

C++ 标准对此非常清楚,来自 [dcl.init]:

If a program calls for the default initialization of an object of a const-qualified type T, T shall be a class type with a user-provided default constructor.

所以gcc在这方面是不合规的,cppreference是正确的。