https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84367
--- Comment #2 from Frederic Tingaud <ftingaud at gmail dot com> --- I reran the test with GCC 7.3, but got the same error: #include <sstream> #include <cassert> #include <iostream> int test() { std::ostringstream oss; std::cerr << "\nRunning with GCC v" << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << " - libc++=" << __GLIBCXX__ << std::endl; for (int i = 0; i < 100; ++i) { oss << "abc"; std::cerr << i << " "; assert(oss.str() == "abc"); oss = std::ostringstream(); } return 0; } output: Running with GCC v7.3.0 - libc++=20180125 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 file.cpp:13: int test(): Assertion `oss.str() == "abc"' failed. Aborted