Garbled iostream output using libstdc++-v3

Gerald Pfeifer pfeifer@dbai.tuwien.ac.at
Wed Nov 22 03:02:00 GMT 2000


Perhaps I am missing something obvious, but the following program worked
fine for me with GCC 2.95.2 and current CVS sources before we switched to
libstdc++-v3.

Now, if I have the program print it's output to the console or to a file
by means of tee (a.out | tee filename), everything is fine and I tell get
the desired output:

  {alpha6beta2}

  {gamma8delta9}

However, once I pipe the output to a file (a.out > filename), all I get is:

  {{gamma8delta9}

Tested on i686-pc-linux-gnu, i386-unknown-freebsd4.2, sparc-sun-solaris2.6
with a statically linked binary (g++ -static prog.cc).

Apparently, the line I marked in the source is critical.

Gerald

-------- cut --------
#include <iostream>

using namespace std;

void p(char *s, char *, int u) {
  cout << s << u;
}

main() {
  cout << '{';
  p("alpha","sixtus",6);
  p("beta","bi",2);
  cout << '}' << endl;

  cout << endl; // Apparently this line is critical!

  cout << '{';
  p("gamma","octal",8);
  p("delta","nona",9);
  cout << '}' << endl;
}



More information about the Libstdc++ mailing list