From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: EMACS_INT vs int for range checking Date: Sat, 26 May 2012 02:13:48 -0700 Organization: UCLA Computer Science Department Message-ID: <4FC09ECC.5050206@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1338023644 14396 80.91.229.3 (26 May 2012 09:14:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 26 May 2012 09:14:04 +0000 (UTC) Cc: Emacs Development To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 26 11:14:03 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SYD4T-0007FI-EW for ged-emacs-devel@m.gmane.org; Sat, 26 May 2012 11:14:01 +0200 Original-Received: from localhost ([::1]:34405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYD4S-0004oQ-VH for ged-emacs-devel@m.gmane.org; Sat, 26 May 2012 05:14:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYD4Q-0004kR-DI for emacs-devel@gnu.org; Sat, 26 May 2012 05:13:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SYD4O-0002C6-RE for emacs-devel@gnu.org; Sat, 26 May 2012 05:13:57 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:59588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYD4M-0002Aj-2X; Sat, 26 May 2012 05:13:54 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id E645CA60003; Sat, 26 May 2012 02:13:43 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nii8i3R2k12S; Sat, 26 May 2012 02:13:43 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6EF49A60002; Sat, 26 May 2012 02:13:43 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150644 Archived-At: Re this patch in trunk bzr 108374: === modified file 'src/bidi.c' --- src/bidi.c 2012-04-09 22:54:59 +0000 +++ src/bidi.c 2012-05-26 07:03:39 +0000 @@ -204,7 +204,7 @@ val = CHAR_TABLE_REF (bidi_mirror_table, c); if (INTEGERP (val)) { - EMACS_INT v = XINT (val); + int v = XINT (val); if (v < 0 || v > MAX_CHAR) abort (); It's true that 'val' is supposed to be in range here, and that if it is in range then 'int' will do. But the point of the test '(v < 0 || v > MAX_CHAR)' is to abort if there is some programming error somewhere that causes 'val' to be out of range. Unfortunately the patch means the abort test won't work reliably on a typical 64-bit host if XINT (val) is (say) 2**32, which means that the programming error won't be detected reliably. If we know with absolute certainty that 'val' is in 'int' range, but there's a reasonable doubt that it's in character range, a comment explaining this would help clarify why 'v' is int. However, it may be simpler (and it's no less efficient) to make v an EMACS_INT.