|
From: | Paul Eggert |
Subject: | Re: Floating-point constant folding in Emacs byte compiler |
Date: | Thu, 22 Mar 2018 22:22:25 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
Stefan Monnier wrote:
I'm pretty sure those runtime differences are not on-purpose
Although that's most likely true for the examples I gave, it's a problematic assumption for code that intentionally inspects runtime behavior.
I mention this because my recently-installed byte-opt patch fixed a problem of this sort with lsh. byte-opt was evaluating (lsh -1 -1) at compile-time, whereas the intent of the (lsh -1 -1) was to calculate most-positive-fixnum at run-time. It's not hard to imagine similar sorts of code to inspect properties of the machine's floating-point behavior, code that would yield the wrong value if compiled on a machine with different floating-point properties.
Nowadays Emacs hosts almost invariably use IEEE floating point, and I suppose we could hardwire that assumption into Emacs. Even so, IEEE floating-point is not bit-for-bit identical on all platforms, so if we're constant-folding floating-point expressions surely we should at least document that we're doing so, so that programmers know that they can't rely on constant expressions yielding a different value than what run-time evaluation would deliver.
[Prev in Thread] | Current Thread | [Next in Thread] |