This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

EOF after __copy_streambufs


Is the EOF after copying streambufs from iss to cout valid (g++ 3.0.1)?

  #include <iostream>
  #include <strstream>

  int
  main( int argc, const char* argv[] )
  {
      const char* data = "first line # comment\n\
  second line\n\
  # commentary line\n\
  last line\n";

      std::istrstream iss( data );
      std::cout << "Original:" << std::endl << iss.rdbuf();
      short state = std::cout.rdstate();
      std::cout.clear();
      std::cout << "flags: " << std::hex << state << std::endl;
      return 0;
  }

When run, I get:

  Original:
  first line # comment
  second line
  # commentary line
  last line
  flags: 2

which is indicates that cout's ios::eofbit was set. It gets set by the
__copy_streambufs template function in streambuf.tcc. When the above code is
compiled under Sun's Forte v5, the eofbit does not get set. Which is correct?

Thanks,

Brad


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