Mail Archives: pgcc/1998/11/23/02:53:14
My g++ program compiled just fine under pgcc-1.1-1 using the -O2
flag, but under the same compiler, using the -O3 flag I get some kind
of a segmentation fault error. (stupid me, I should have written it
down... sorry).
I traced the problem and found a way to fix it. Can somebody tell me
if this is a problem in pgcc, or am I doing something silly in my
program? (I'd be happy to send the source code of the broken and no-
longer-broken programs to anyone who is interested; pretty boring
number crunching stuff.)
The debugger showed the problem as occuring in __math.h and the lines
with the problems were of the form...
f[1] = X*y+z*q ... ... ... * pow(a[1],2);
When I changed those lines to be of the form...
a1=a[1];
f[1] = X*y+z*q ... ... ... * pow(a1,2);
then the problem _usually_ went away (behaved for some lines,
misbehaved for other lines --consistently, though, not like I would
expect from some kind of memory failure).
When I changed those lines to be of the form...
a1=a[1];
f[1] = X*y+z*q ... ... ... * (a1*a1) ;
The problems vanished.
Strange.
One last observation... In __math.h (using xxgdb), as the program
terminated due to error, the problem always seemed to be that the
input variable associated with a1 in the "pow" function had an
undefined value.
Many times I've thought I'd found compiler bugs and they always
turned out to be bad programming. Can anyone see any obvious
programming errors in this? Could this really be some kind of bug?
Thanks.
Christopher D. Morgan
morganc5 AT asme DOT org
It's trivial to make fun of Microsoft products,
but it takes a real man to make them work, and
a god to make them do anything useful.
For my always up-to-date contact information, click here:
http://www.planetall.com/main.asp?cid=1680904
It's private, secure, and free!
- Raw text -