tellg/tellp() can change state of stream ?
Canal Vorfeed
canalvorfeed@mail.ru
Fri May 20 00:47:00 GMT 2005
Zidrav 1.1 does not work with gcc 3.4.3 ...
Since it's trivial program I tried to understand what goes on and reduced testcase to this:
-- cut --
#include <iostream>
#include <fstream>
char buf[4]={'\1','\2','\3','\4'};
main() {
std::fstream testFile;
testFile.open("test", std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc );
testFile.write(buf,2);
testFile.seekp(0);
testFile.read(buf,2);
// testFile.tellg();
testFile.write(buf+2,2);
testFile.close();
}
-- cut --
If you'll uncomment tellg() call it works in the 3.4.3 the same way as in 3.3.5 (file will be 4 bytes in size: \1\2\3\4), without this call file will have just two bytes: \1\2 ... Where \3\4 are gone is anyone's guess...
Tested with Gentoo ~x86 and Fedora core 3.
More information about the Libstdc++
mailing list