Messages in this thread | | | Subject | Re: floating-point abuse in 2.1.113 | Date | Wed, 5 Aug 1998 23:38:01 +0200 (MEST) | From | (Rogier Wolff) |
| |
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.
-- Actor asks a collegue: "To what do you owe your success in acting?" Answer: "Honesty. Once you've learned how to fake that, you've got it made." -------- Custom Linux device drivers for sale! Call for a quote. ---------- Email: R.E.Wolff@BitWizard.nl || Tel: +31-15-2137555 || FAX: +31-15-2138217
- 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
| |