www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1998/11/23/02:53:14

X-pop3-spooler: POP3MAIL 2.1.0 b 4 980420 -bs-
X-Authentication-Warning: basis.Desk.nl: listserv set sender to owner-beastium-list AT basis DOT desk DOT nl using -f
Message-Id: <199811230247.VAA09085@acheron.aldhfn.org>
From: "Christopher D. Morgan" <morganc5 AT asme DOT org>
Organization: The Morgan Family
To: beastium-list AT desk DOT nl
Date: Sun, 22 Nov 1998 21:38:49 -0500
MIME-Version: 1.0
Subject: math.h problem, inline functioning
Reply-to: morganc5 AT asme DOT org
X-mailer: Pegasus Mail for Win32 (v3.01b)
Sender: Marc Lehmann <pcg AT goof DOT com>
Status: RO
X-Status: A
Lines: 51

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019