GNU bug report logs - #42597
27.1; (+ -0.0) returns +0.0 when compiled

Previous Next

Package: emacs;

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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mattias Engdegård <mattiase <at> acm.org>
Subject: bug#42597: closed (Re: bug#42597: 27.1; (+ -0.0) returns +0.0
 when compiled)
Date: Fri, 07 Aug 2020 08:53:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#42597: 27.1; (+ -0.0) returns +0.0 when compiled

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 42597 <at> debbugs.gnu.org.

-- 
42597: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=42597
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Mattias Engdegård <mattiase <at> acm.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 42597-done <at> debbugs.co.uk
Subject: Re: bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled
Date: Fri, 7 Aug 2020 10:50:19 +0200
No immediate objections at least; patches pushed to master.



[Message part 3 (message/rfc822, inline)]
From: Mattias Engdegård <mattiase <at> acm.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; (+ -0.0) returns +0.0 when compiled
Date: Wed, 29 Jul 2020 14:07:32 +0200
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 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.