When ignoring the number of bytes available in a streambuf using std::istream::ignore, ignore calls underflow. This should not happen. I feel the easiest way to reproduce it is to look at strace output when ignoring bytes from ifstream:
#include <iostream> #include <fstream> int main(int argc, char* argv[]) { std::ifstream in(argv[0]); in.get(); // trigger filling of input buffer by calling underflow in.ignore(in.rdbuf()->in_avail()); // this triggers another underflow } The strace output shows, that 2 calls to read with 8191 bytes occures. When ignoring one byte less and then another byte, only one read is done: #include <iostream> #include <fstream> int main(int argc, char* argv[]) { std::ifstream in(argv[0]); in.get(); // trigger filling of input buffer in.ignore(in.rdbuf()->in_avail() - 1); in.ignore(1); // this does not trigger underflow } -- Summary: std::istream::ignore(std::streamsize n) calls unnecessary underflow Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tommi at tntnet dot org GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42857