My understanding is that with fstream, get and put pointers move together.  
Therefore expect output of following to be aabbc1234, output is actually aabbc.
This had expected result with 3.3.1, unexpected result with 3.4.4.


#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
fstream myStream;
myStream.open("myTestFile.out", ios_base::in | ios_base::out | ios::trunc);
// write "aabbc" to file
myStream.put('a');
myStream.put('a');
myStream << "b";
myStream << "b";
myStream << "c";
//rewind
myStream.seekg(0);
char c;
//skip over data
for (int i=0; i < 5; i++) {
myStream.get(c);
}
// append 1234 to file
myStream << "1234\n";
myStream.close();
return 0;
}


Configured with: ./configure --prefix=/usr/local/gcc-3.4.4
Thread model: posix
gcc version 3.4.4


-- 
           Summary: fstream get/put pointers have unexpected positions
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: elizbus at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40732

Reply via email to