BUG? Tied streams on i686...
Fred Richardson
frichard@benzene.bbn.com
Mon Feb 2 14:54:00 GMT 1998
Hi-
I've been trying to debug some tied stream code that used to work, but
no longer does. The major change is that I'm now using RH 5.0 and
glibc 2. The code works on my Solaris 2.5 Sparc box with EGCS.
Basically, I have an istream whose buffer is tied to a ostrstream
which I'm writing to and reading from. Here's my main.cc:
#include <iostream>
#include <strstream>
#include <string>
int main()
{
ostrstream oss;
istream is(oss.rdbuf());
is.clear();
string out_str;
string in_str;
out_str = "This is a test";
oss << out_str;
while (! is.eof())
{
is >> in_str;
cout << in_str << endl;
}
is.seekg(0, ios::end);
oss.clear();
is.clear();
out_str = "This is another test";
oss << out_str;
while (! is.eof())
{
is >> in_str;
cout << in_str << endl;
}
}
On the SPARC, this produces:
% g++ -o TMP main.cc
% TMP
This
is
a
test
This
is
another
test
%
But on the i686, it produces:
% g++ -o TMP main.cc
% TMP
This
is
a
test
test
%
Is my code wrong? Is this another problem with libio and glibc 2?
Thanks once again for any help with this,
-Fred
More information about the Gcc-bugs
mailing list