I will go straight to MCVE:
#include <sstream>
struct A
{
inline static std::stringstream ss;
};
GCC 7.2 and 7.1 refuse to compile with the following error:
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
You can reproduce this without any flags, as well as with -std=c++17
.
Clang 5.0 compiles it without any problems.
Other classes (e.g. std::string
) can be made inline static
without problems.
Troubleshoot using the built-in static file.
Is GCC a bug or am I missing something?
source
share