[Bug libstdc++/44441] New: std::getline set failbit in situation when shouldn't
In this code s failbit is set if last line in s is empty (stream ends with \n\n): std::istream s; //s is some kind of input stream like std::istringstream s("\n\n"); while (s.good()) { std::string line; std::getline(s, line); } -- Summary: std::getline set failbit in situation when shouldn't Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: qwak82 at gmail dot com GCC host triplet: ubuntu linux x86-64 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1
[Bug libstdc++/44441] std::getline set failbit in situation when shouldn't
--- Comment #2 from qwak82 at gmail dot com 2010-06-07 11:36 --- But also fail bit, this program prints: line: a //this is OK, first line line://this is also OK, second (empty) line fail bit //eof is set - OK; but fail bit should be set here? #include #include int main() { std::istringstream s("a\n"); while (s.good()) { std::string line; std::getline(s, line); std::cout << "line: " << line << std::endl; } if (s.fail()) std::cout << "fail bit"; return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1