GNU bug report logs -
#30408
24.5; (format "%x" large-number) produces incorrect results
Previous Next
Reported by: David Sitsky <david.sitsky <at> gmail.com>
Date: Sat, 10 Feb 2018 07:03:02 UTC
Severity: wishlist
Found in version 24.5
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Here's a patch that I hope addresses the main problem. The basic idea is
to avoid the confusion exemplified in Bug#30408 by changing Emacs so
that it ordinarily signals an error if it reads a program that contains
an integer literal that is out of fixnum range. However, if the
out-of-range literal is followed by '.' then Emacs continues to silently
convert it to floating-point; this is intended as an escape hatch for
any programs that need the old behavior (I expect this'll be rare).
Thus, on 32-bit Emacs, plain '536870912' in a program causes Emacs to
signal an overflow while loading the program, whereas '536870912.' is
treated as a floating-point number as before. (On 64-bit Emacs, the same
two literals are both integers, as before.)
Unlike my previous proposal, this patch does not affect the behavior of
string-to-integer. As I understand it, that was a primary source of
qualms about the previous proposal.
I've tested this on both 32- and 64-bit Emacs on master. This patch has
helped me to find a couple of integer portability bugs which I already
fixed on master.
[0001-Lisp-reader-now-checks-for-integer-overflow.patch (text/x-patch, attachment)]
This bug report was last modified 7 years and 77 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.