🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Timothy Miller Mon, 04 Mar 1996 04:36
HELP!: Optimizer problem ??
#914
Author: Timothy Miller
Date: Mon, 04 Mar 1996 04:36
44 lines
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads