This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

BUG? Tied streams on i686...


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]