This is the mail archive of the libstdc++@sourceware.cygnus.com 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]

Re: mailing list improvements and bug tracking database now online.



OK, I posted my bug to the libstdc++ bug tracking system, but just to
make sure it gets to the right place, here it is as well.

"Writing large strings (>5000 bytes or so) to an ofstream causes
the stream to go bad."

Here is the test program which exposes the problem.
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>

const int i_max=250;

void test(int size)
{
  int i;

  string filename;
  std::ofstream f("out.log");

  std::cout << "Testing with size " << size << std::endl;
  std::cout << "State of f:" << f.good() << std::endl; 
  string x(size, 'c');

  f << x << endl;
  std::cout << "State of f:" << f.good() << std::endl; 
  if (!f.good()) exit(1);

  f << x << endl;
  std::cout << "State of f:" << f.good() << std::endl; 
  if (!f.good()) exit(1);

  f.close();
  return;
}

int main()
{

  test(1000); 
  test(10000);
}





On my system I get:
nano:~/src/TestStdC++
:./test7

Testing with size 1000
State of f:1
State of f:1
State of f:1
Testing with size 10000
State of f:1
State of f:0                 

Dave

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