[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EMACS_INT vs int for range checking
From: |
Paul Eggert |
Subject: |
EMACS_INT vs int for range checking |
Date: |
Sat, 26 May 2012 02:13:48 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
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.
- EMACS_INT vs int for range checking,
Paul Eggert <=