This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
ostream with 0 constructor
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: ostream with 0 constructor
- From: Stephen Vavasis <vavasis at CS dot Cornell dot EDU>
- Date: Fri, 23 Apr 1999 21:36:37 -0400
- Organization: Cornell University
- Reply-To: vavasis at CS dot Cornell dot EDU
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;
}