This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Spurious runtime error using g++ under Linux
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Spurious runtime error using g++ under Linux
- From: Gary Neil Felder <gfelder at leland dot Stanford dot EDU>
- Date: Tue, 28 Sep 1999 08:23:34 -0700 (PDT)
- Reply-To: Gary Neil Felder <gfelder at leland dot Stanford dot EDU>
I am running gcc under Linux 6.0 on a Pentium II 450. When I tried
compiling and running a program which I had written on a different system
it gave me a runtime "segmentation fault" error. I reduced the program to
the simplest form which I could that still contained the error, and I now
have it down to about 20 lines of code which to me look completely
harmless, but which consistently reproduce this error.
Running g++ -v indicates that I have version 2.91.66 of gcc. I'm including
the makefile and source files I used so that you can see exactly what
options I used. To reproduce the error I simply put all of these files in
a directory and type:
make
./sfe
Note that I copied these files to a UNIX system and the problem did not
appear so I suspect it may be specific to Linux. I also copied them to
another Linux machine and the problem did show up again.
Thank you for your help.
Gary Felder
gfelder@stanford.edu
#include "complex.h"
Complex :: Complex(float real, float imag) : real_(real), imag_(imag)
{ }
/*
Complex :: Complex(const Complex& c)
{
real_ = c.real_;
imag_ = c.imag_;
}
Complex& Complex :: operator=(const Complex& c) // Assignment operator
{
real_ = c.real_;
imag_ = c.imag_;
return *this;
}
*/
class Complex
{
public:
Complex(float real = 0, float imag = 0); // Default
// Complex(const Complex& c); // Creates a copy of c
// Complex& operator=(const Complex& c); // Assignment operator
private:
float real_;
float imag_;
};
CC = g++
FLAGS = -O3
all: complex.h complex.o sfe.o
$(CC) $(FLAGS) complex.o sfe.o -lm -o sfe
clean:
rm -f *.o sfe
complex.o: complex.cpp complex.h
$(CC) -c $(FLAGS) complex.cpp
sfe.o: sfe.cpp
$(CC) -c $(FLAGS) sfe.cpp
#include "complex.h"
#include <math.h>
#include <stdio.h>
float psm;
int main()
{
Complex af;
float xmax=10.5;
printf("generating initial conditions ...\n");
psm=pow(xmax,1.5);
return(0);
}