Querying the position in a file uses filebuf::seekoff( 0, ios::cur ). Although the Standard specifies that this combination of parameters does not flush putback or the output sequence, it does anyway, which results in a performance hit. (§27.8.1.4/11)
Regression: http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/include/bits/fstream.tcc?r1=68163&r2=68420 (@@ -473,41 +486,26 @@) This has been broken a long time! -- Summary: std::fstream::tellg invalidates I/O buffer Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: potswa at mac dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45628