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]

ostream with 0 constructor


The code below does not work in egcs-1.1.2 running under Sun Solaris
2.5.1.  It compiles OK (no arguments passed to g++ other than the source
file name), but when executed, it gives a segmentation fault.

I believe that an ostream constructed with an argument of 0 is supposed
to discard all its characters and do nothing.  This is how ostream works
in KCC 3.2f and VC++5.0. 

Assuming that the program below really does indicate an egcs bug (rather
than my incorrect understanding of ostream), can someone tell me the
workaround?  How do I create an ostream that discards all its output?

Thanks,
Steve Vavasis

#include <iostream>

using std::ostream;
using std::endl;

int main() {
  ostream nullstr(0);
  nullstr << "hello world" << endl;
  return 0;
}


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