为什么 GCC 不允许我创建 `inline static std::stringstream`?

Why GCC doesn't allow me to create `inline static std::stringstream`?

我直接去MCVE:

#include <sstream>

struct A
{
    inline static std::stringstream ss;
};

GCC 7.2 和 7.1 refuse to compile 它有以下错误:

错误:没有匹配函数来调用 'std::__cxx11::basic_stringstream::basic_stringstream()'
     内联静态 std::stringstream ss;
                                     ^~
blah:1:0 包含的文件中:
/opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7: 注意:候选:std::__cxx11::basic_stringstream::basic_stringstream(std::__cxx11::basic_stringstream&&) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]
       basic_stringstream(basic_stringstream&& __rhs)
       ^~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7: 注意:候选人需要 1 个参数,提供 0 个参数

您可以在没有任何标记的情况下重现它,也可以使用 -std=c++17

Clang 5.0 编译没有任何问题。

其他类(例如std::string)可以inline static没问题

使其成为非内联静态可消除错误。

这不是 GCC 错误还是我遗漏了什么?

错误。减少到:

struct C { explicit C() {} };
struct A {
    inline static C c;
};

GCC 初始化处理代码中的某处错误地将其视为忽略显式默认构造函数的复制初始化上下文..