Bug with cerr,cout and flush in gcc 3.1 -- solid example.
Thaddeus L. Olczyk
olczyk@interaccess.com
Tue Jul 9 17:42:00 GMT 2002
I sent this to the general gcc list, but then I realised it might be
better here.
My apologies. I sent a message to the wrong address then overwrote it
with this message before I sent, so it's gone. Eventually I will get
it back and include any information I may have forgotten in a
followup.
I've noticed a bug is g++. It occurs when you call flush on cerr or
cout and link the boost regex library. This happens on a Dual PII-450.
Linux kernel 2.4.8.
Here is a simple example of the bug:
---------------------main.cpp------------------------
#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc,char *argv[])
{
printf("Hello World.\n");
cout<<"Hello World."<<endl;
#ifdef CRASH
cout.flush();
#endif
}
------------------------------------------------------
g++ -gstabs+ -DCRASH main.cpp
-LWhatever_directory_you_store_libboost_in -lboost_regex_debug
./a.out
Hello World.
Hello World.
g++ -gstabs+ main.cpp -LWhatever_directory_you_store_libboost_in
-lboost_regex_debug
./a.out
Segmentation violation
The problem appears when you have a call to flush ( I've only checked
with cerr and cout ) and link the boost regex library.
More information about the Gcc-bugs
mailing list