ostream with 0 constructor
Stephen Vavasis
vavasis@CS.Cornell.EDU
Fri Apr 23 18:36:00 GMT 1999
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;
}
More information about the Gcc-bugs
mailing list