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]

run-time g++ bug


The attached segfault.c++ compiles with no errors, but the executable
terminates with a segmentation fault when compiled with optimisations
on, i.e:

g++ -O -o tsf test-segfault.c++

but runs fine when compiled without the -O flag.

I'm using version egcs-2.91.66 under Red Hat 6.0.

Please take a look at the attached file; it is only 12 lines of simple
code with nothing to warrant any run-time errors.

Steve

PS. If you can spare I would really appreciate some feedback on this
problem.
#include <iostream.h>
#include <math.h>

class C{
 public:
	double *p;
	int N;
	double *mu;
	
	C();
};

C::C():p(NULL), N(0), mu(NULL){}

void main(){
	C c;
	double a = pow(2,2);
	cout << a;
}

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