From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: integer overflow handling for most-negative-fixnum Date: Sat, 21 Jul 2018 16:42:03 -0400 Message-ID: References: <867elsq78b.fsf@gmail.com> <866018yl76.fsf@gmail.com> <83a7qkzyhz.fsf@gnu.org> <83d0vgxxx8.fsf@gnu.org> <837eloxw0y.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1532205611 3421 195.159.176.226 (21 Jul 2018 20:40:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 21 Jul 2018 20:40:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 21 22:40:07 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 1fgyfe-0000jO-PW for ged-emacs-devel@m.gmane.org; Sat, 21 Jul 2018 22:40:06 +0200 Original-Received: from localhost ([::1]:53929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgyhk-0000Fr-6Q for ged-emacs-devel@m.gmane.org; Sat, 21 Jul 2018 16:42:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgyhd-0000FZ-W1 for emacs-devel@gnu.org; Sat, 21 Jul 2018 16:42:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgyhd-00060B-5M for emacs-devel@gnu.org; Sat, 21 Jul 2018 16:42:10 -0400 Original-Received: from pmta21.teksavvy.com ([76.10.157.36]:35580) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1fgyhZ-0005zZ-Ey; Sat, 21 Jul 2018 16:42:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2GHBgAEmlNb/37rr2xcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYNNgWKISoQ/i1MBggsTHgGXBQuEZgQCAoMMIjgUAQIBAQEBAQECAgJ?= =?us-ascii?q?pKIU5AQQBViMQCzQSFBgNJIUrCK9oik6LGIQiilMCmWwJkHWGTDSFLZIVDIFYI?= =?us-ascii?q?oFSMxoIMIMlkG4jjmoBAQ?= X-IPAS-Result: =?us-ascii?q?A2GHBgAEmlNb/37rr2xcGgEBAQEBAgEBAQEIAQEBAYNNgWK?= =?us-ascii?q?ISoQ/i1MBggsTHgGXBQuEZgQCAoMMIjgUAQIBAQEBAQECAgJpKIU5AQQBViMQC?= =?us-ascii?q?zQSFBgNJIUrCK9oik6LGIQiilMCmWwJkHWGTDSFLZIVDIFYIoFSMxoIMIMlkG4?= =?us-ascii?q?jjmoBAQ?= X-IronPort-AV: E=Sophos;i="5.51,386,1526356800"; d="scan'208";a="40083773" Original-Received: from 108-175-235-126.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([108.175.235.126]) by smtp.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jul 2018 16:42:03 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 2E2EEAE0E4; Sat, 21 Jul 2018 16:42:03 -0400 (EDT) In-Reply-To: <837eloxw0y.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Jul 2018 21:51:09 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.10.157.36 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:227642 Archived-At: >> When the user wrote #x3fffffffffffffff to mean "the positive number >> written as 3fffffffffffffff in hexadecimal" > There's no such positive number, at least not as fixnum. That's no excuse to turn around and return a negative number instead. If I try to read too large a decimal number, Emacs signals an `overflow-error` instead of returning a negative number, so it makes sense to do the same for hexadecimal numbers. >> You can only read it as "-1" based on an assumption of fixed-width >> two's-complement representation but the bitwidth of Emacs numbers is >> something that can change between Emacs versions and >> compilation options. > I'm talking about an Emacs with 64-bit EMACS_INT. Right, but the reader is designed to `read` files which are usually not specific to a given build (historically, there have been some build-dependence on the result of `read`, but we've generally considered them as bugs or misfeatures). Stefan