Re: floating-point abuse in 2.1.113

Richard B. Johnson (root@chaos.analogic.com)
Wed, 5 Aug 1998 17:45:01 -0400 (EDT)


On Wed, 5 Aug 1998, Rogier Wolff wrote:

> Richard B. Johnson wrote:
> > foo = (int) (1.1 * 1.2 * 1.3 * 1.4);
> > printf("%d\n", foo);
> >
> > }
> [...]
> > movl $2,-4(%ebp) ; <- Note!
> > movl -4(%ebp),%eax
> > pushl %eax
>
> So, let us conclude that the original author might have though about
> it and concluded that only ints would go into the binary (if the
> compiler would properly optimize it), so that it wouldn't be a problem.
>
> Let's decide right now that this reasoning is "off limits" and should
> be avoided.
>
> If you suspect a compiler bug that has to do with optimizing, you
> might want to compile the kernel with less optimization to see if that
> fixes the obscure bug that you're seeing. If that introduces new bugs
> (due to the fp unit not getting saved/restored) then we're in deep
> shit.
>
> Conclusion: Yes, you could use an FP calculation for an integer
> constant and get the compiler to convert to integer before creating
> the binary. However we don't want to depend on the compiler for
> this to happen ALL the time.....
>
> Roger.

I agree entirely.

Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.113 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html