seek problem on strstream
Benoit MAIRE
Benoit.M@dalim.com
Mon Oct 21 02:41:00 GMT 2002
With the following version of the compiler, I have a strange result.
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-112)
It seems that seekp give a bad result after a write in this case. All
works fine up to byte number 3101.
Result given is :
0
4
I hopped a result of
0
0
The same code works fine on SGI with SGI compilers. It also work on
linux with gcc3.
Is there a known limitation of strstream or a bad usage in this code or
is it a library bug ?
Benoit
#include <strstream.h>
#include <iostream.h>
#include <string.h>
int main( int, char** )
{
strstream s;
char buff[3429];
memset( buff, 'A', sizeof buff );
char tmp[10];
memset( tmp, 'B', sizeof tmp );
s.write( buff, 3429 );
s.seekp( 0 );
s.write( tmp, 10 ); // This write makes the stream to fail for a seek
after byte 3102
s.seekp( 3101 );
cout << s.fail() << endl;
s.seekp( 3102 );
cout << s.fail() << endl;
return 0;
}
More information about the Gcc-bugs
mailing list