[ODE] Different behaviors with different C++ compilers

Adam D. Moss aspirin at ntlworld.com
Wed Jul 2 11:09:01 2003


Steffen Wischmann wrote:
> I ran my simulation (Creature with NN Controller) on two differnt linux 
> distribution, one with the gcc compiler ver. 3.2-36, the other one with 
> ver.  2.95.3-52. I'm using ode 0.035 on both machines.
> If I compile the code with the older compiler, and copy the compiled 
> code to the machine with the newer compiler version, I got exactly the 
> same behavior. But if I compile the same source code again with the 
> newer compiler version, the behavior is different.
> 
> Does anybody know something about that?

That's pretty much to be expected.  C(++) compilers have quite
a lot of leeway in the expression re-ordering they're allowed
to do and the size of the floats used as temporaries, for
fp maths, where worst-case precision of an operation is usually a
function of the float size but best-case is very unpredictable (in
gcc this can vary from compilation to compilation depending on whether,
for example, a fp variable stayed in a register for the duration of
its lifespan or whether it temporarily pushed to a minimal-sized
memory location while some other maths hogged the fp registers).
So unlike integers maths, you're really not very likely to get
precisely the same results from two quite different compilers when
doing heavy fp processing -- and for something like a game or a
simulation, that small drift in precision builds up to something
quite visible.

--Adam
-- 
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3
"When I was young, I would break down and cry whenever mom made me
throw an empty toilet paper tube in the trash can. I just imagined
it sitting at the dump, all cardboard and sad." -- T.Farnon