[Bug rtl-optimization/323] optimized code gives strange floating point results
jonathan at csse dot uwa dot edu dot au
gcc-bugzilla@gcc.gnu.org
Mon Oct 4 10:57:00 GMT 2004
------- Additional Comments From jonathan at csse dot uwa dot edu dot au 2004-10-04 10:57 -------
Some musings based on my encounter with this bug...
Comparison of doubles is not just restricted to numerical analysis. Bug report
17802 (aka #323) arose out of a binary search of a timer queue. Is it wrong to
assume that if "int secs = 2" and "int usecs = 100000" then "secs + 1e-6 *
usecs" will return the same result every time it is evaluated as an inline function?
Calling a trivial function twice with an identical parameter may return a value
less than, equal to or greater than itself (depending on register allocation in
the context of the calls). This is a really nasty piece of nondeterministic
behaviour. Weren't compilers and "high level" languages invented to get around
exactly this kind of hardware dependency?
Compiling with -ffloat-store did not help in my case. Compiling without -O
isn't always possible either. Since the function that causes the problem is the
trivial calculation above, inlined for performance, I can't guarrantee that
every user of the header file it appears in will know to compile without -O (or
be willing to). The outcome will be users reporting a bug in my code.
This bug is being reported regularly, and probably affecting a lot more people
that don't report it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
More information about the Gcc-bugs
mailing list