GNU bug report logs -
#42597
27.1; (+ -0.0) returns +0.0 when compiled
Previous Next
Reported by: Mattias Engdegård <mattiase <at> acm.org>
Date: Wed, 29 Jul 2020 12:41:01 UTC
Severity: normal
Tags: patch
Found in version 27.1
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Unary +, *, min and max, all of which should be identity for numbers, convert -0.0 to +0.0 when byte-compiled:
(defun f (x) (+ x))
(f -0.0)
=> -0.0
(byte-compile 'f)
(f -0.0)
=> 0.0
The reason is that byte-compile-associative transforms (+ x), (* x), (min x) and (max x) into (+ x 0).
No patch yet (sorry!) but I'm not sure what would be the best way to go about it. Some possibilities:
A. Use a full 1-argument call, like (+ x). This is more expensive (about 1.8×) since the general function call mechanism has to be used.
B. Use (* x 1) instead; this appears to work. This is also more expensive (1.6×); not sure why.
C. Add a new byte-op. Fast but probably overkill.
Better suggestions welcome!
This bug report was last modified 4 years and 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.