From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: integer overflow handling for most-negative-fixnum Date: Mon, 23 Jul 2018 22:11:15 +0100 Message-ID: <86fu091wuk.fsf@gmail.com> References: <867elsq78b.fsf@gmail.com> <866018yl76.fsf@gmail.com> <1d61916e-efa5-62f9-b76e-afb7da8665fd@cs.ucla.edu> <85674d39-4e97-cec6-b40a-cd31bf71b690@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1532382248 4522 195.159.176.226 (23 Jul 2018 21:44:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 23 Jul 2018 21:44:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 23 23:44:04 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fhice-00013H-0U for ged-emacs-devel@m.gmane.org; Mon, 23 Jul 2018 23:44:04 +0200 Original-Received: from localhost ([::1]:36916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiek-0005wT-Tk for ged-emacs-devel@m.gmane.org; Mon, 23 Jul 2018 17:46:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi7A-0007Xq-8m for emacs-devel@gnu.org; Mon, 23 Jul 2018 17:11:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhi77-00082z-5U for emacs-devel@gnu.org; Mon, 23 Jul 2018 17:11:32 -0400 Original-Received: from [195.159.176.226] (port=41957 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhi76-00082A-T2 for emacs-devel@gnu.org; Mon, 23 Jul 2018 17:11:29 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fhi4u-000450-1Y for emacs-devel@gnu.org; Mon, 23 Jul 2018 23:09:12 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:HsMxSh2JPOMwFVQoiOHpLNww6Js= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:227748 Archived-At: On Mon 23 Jul 2018, Paul Eggert wrote: > Andy Moreton wrote: >> I see that you have pushed 57c4bc146b ("0x%x → %#x in elisp formats"), >> which will cause breakage as format is not well behaved: >> >> ELISP> (format "%#x" 1) >> "0x1" >> ELISP> (format "%#x" 0) >> "0" ; Missing "0x" prefix (same misfeature as in C) >> >> ELISP> (format "%#08x" 1) >> "0x000001" ; Wrong number of digits printed >> ELISP> (format "%#08x" 0) >> "00000000" >> >> For both of the above reasons, this change is not a good idea. > > Thanks for mentioning the issue, as I had forgotten that (format "%#x" 0) > yields "0" not "0x0". However, I don't see how 57c4bc146b breaks anything. The > generated strings are used as nonces or arbitrary labels and as far as I can > see nobody cares whether 0 is printed as "0" or as "0x0". (As none of the > changes involve anything like "%#08x" I don't see the relevance of your second > example.) The breakage is that anything expected to line up nicely in columns is broken when "0x%x" is replaced by "%#x" as any zero values are no longer the same output width. Also, if the width is specified as 8 I expect to see 8 digits of output, not 6. > I now notice that this wrinkle about 'format' isn't documented despite being > longstanding behavior that mirrors the C standard. It should be documented, so > I installed the attached patch into master to fix the oversight. Thanks for the doc fix. While I think this is a misfeature in C and in elisp, it is decades too late to change the behaviour. AndyM