C++ 为什么GCC不';不允许我创建“内联静态std::stringstream”?

C++ 为什么GCC不';不允许我创建“内联静态std::stringstream”?,c++,gcc,stringstream,C++,Gcc,Stringstream,我直接去MCVE: #include <sstream> struct A { inline static std::stringstream ss; }; #包括 结构A { 内联静态标准::stringstream ss; }; GCC 7.2和7.1中有以下错误: error: no matching function for call to 'std::__cxx11::basic_stringstream::basic_stringstream()'

我直接去MCVE:

#include <sstream>

struct A
{
    inline static std::stringstream ss;
};
#包括
结构A
{
内联静态标准::stringstream ss;
};
GCC 7.2和7.1中有以下错误:

error: no matching function for call to 'std::__cxx11::basic_stringstream::basic_stringstream()' inline static std::stringstream ss; ^~ In file included from blah:1:0: /opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7: note: candidate: 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: note: candidate expects 1 argument, 0 provided 错误:调用“std::_cxx11::basic_stringstream::basic_stringstream()”时没有匹配的函数 内联静态标准::stringstream ss; ^~ 在blah:1:0中包含的文件中: /opt/compiler explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7:注:候选:std:uuuCXX11::basic_stringstream::basic_stringstream(std:uCXX11::basic_stringstream&)[带CharT=char;Traits=std::char_Traits;Alloc=std::分配器] 基本字符串流(基本字符串流和右字符串流) ^~~~~~~~~~~~~~~~~~ /opt/compiler explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7:注意:候选者需要1个参数,提供0 您可以在不使用任何标志的情况下,以及使用
-std=c++17
复制它

Clang5.0编译它时没有任何问题

其他类(例如
std::string
)可以毫无问题地成为
内联静态类

将其设置为非内联静态将删除错误

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

错误。减至:

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

GCC初始化处理代码中的某个地方错误地将其视为忽略显式默认构造函数的副本初始化上下文。

您使用的编译器选项是什么?IIRC,
inline
变量是为C++17提出的。您使用的GCC版本是否需要类似于
-std=c++17
的内容?@andrewhole不使用或不使用
-std=c++17
时,不需要其他标志来复制。正如我所说,其他类型的内联静态变量工作得很好?@AndrewHenle C++17已经发布