Bug in egcs-2.91.66 - double comparisons

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Mon Nov 29 13:36:00 GMT 1999


> The problem seems to be with Intel floating point registers,
> which hold more precision than a double. If the compiler
> generates code that compares the registers then the
> result can be different from what is expected.

Yes, but this is not a bug. The compiler is entirely entitled to use
the strategy you explain, and the bug is that the application relies
on a certain method of evaluation.

If you want to write robust code, don't rely on a specific precision
for floating point computations - some processors may not offer that
precision. If you only care about Intel and gcc, use what they
provide.

> Using the "-ffloat-store" option on the compile command line
> is supposed to force storing of doubles back to memory
> before comparisons to avoid this problem. However, my
> example still fails with this option turned on.

You did not read the documentation. It says

     Do not store floating point variables in registers, and inhibit
     other options that might change whether a floating point value is
     taken from a register or memory.

So with -ffloat-store, you'll get *variables* into the stack, not any
intermediate value.

What wording should I add to the FAQ to make this clear????

Regards,
Martin


More information about the Gcc-bugs mailing list