Article View: gnu.g++.help
Article #914HELP!: Optimizer problem ??
From: Timothy Miller
Date: Mon, 04 Mar 1996 04:36
Date: Mon, 04 Mar 1996 04:36
44 lines
2382 bytes
2382 bytes
I seem to be having a bit of a problem with g++. This problem seems
rather odd to me, so I have put the complete source code to the project
I'm working on on the web at this address:
http://www.csee.usf.edu/~millert/temp/
(It's a senior project, so if you're interested, you can wait until it's
done and get complete working cleaned up source code to this ray tracer.)
Of particular interest are "sphere.cpp" and "matrix.hpp". Look at line
78 of sphere.cpp. It says this:
n.el(3) = 0;
The code that it expands to is a member of my Matrix class that looks
like this:
double& el(int y, int x=0) { return v[x].el(y); }
The prolbem is that when I use the -O4 optimization setting (actually,
I've only tried it with -O4 and with no optimization), line 78 disappears
completely. It is crucial to the algorythm, but it's never executed. If
optimization is off, the line is executed properly.
If you download the code as it is and run it, it will produce a lot of
junk for output, but in that junk, you'll find that line 79 prints
n.el(3), but the value it prints is not zero. I have tried using n.el(3,
0), and it makes no difference.
Now, I'm not a good enough C++ programmer to feel that I have the right
to suspect a problem with the compiler, so I was wondering if some kind
soul out there could look at my code and see if there is something that
I'm doing wrong that lets it omit that line.
Also, since I'm new at this, I'm open to suggestions pertaining to my
programming style and programming approach.
Thanks.
---------------------------------------------------------------------------
Timothy Miller, millert@grad.csee.usf.edu Theoretical Linguistics
http://www.csee.usf.edu/~millert Music Theory, Computer Engineering
---------------------------------------------------------------------------
Cunning linguists are very skilled with their tongues.
Technical Details
Message-ID:
<Pine.SUN.3.91.960303232330.17862A-100000@bilsby>Path:
arc1-ca.pugleaf.net!mother.usf.edu!bilsby!millertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mother.usf.edu!bilsby!millert From: Timothy Miller <millert@csee.usf.edu> Newsgroups: gnu.g++.help,comp.lang.c++ Subject: HELP!: Optimizer problem ?? Date: Sun, 3 Mar 1996 23:36:43 -0500 Organization: University of South Florida Message-ID: <Pine.SUN.3.91.960303232330.17862A-100000@bilsby> NNTP-Posting-Host: bilsby.csee.usf.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Sender: millert@bilsby