https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81338
Bug ID: 81338 Summary: stringstream remains empty after being moved into multiple times Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zxy19980101 at sina dot cn Target Milestone: --- Given the code below: #include <sstream> #include <iostream> int main() { std::stringstream ss; while (true) { for (int i = rand() % 10 + 10; i > 0; --i) { ss << static_cast<char>(rand() % 26 + 'a'); } std::cout << ss.str() << "\n"; ss = std::stringstream(); } return 0; } The output become blank lines after the first few. The code works on visual studio 2017. My g++ version is: g++.exe (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.