From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs Development <emacs-devel@gnu.org>
Subject: EMACS_INT vs int for range checking
Date: Sat, 26 May 2012 02:13:48 -0700 [thread overview]
Message-ID: <4FC09ECC.5050206@cs.ucla.edu> (raw)
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.
next reply other threads:[~2012-05-26 9:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-26 9:13 Paul Eggert [this message]
2012-05-26 10:11 ` EMACS_INT vs int for range checking Eli Zaretskii
2012-05-26 19:05 ` Paul Eggert
2012-05-27 6:19 ` Eli Zaretskii
2012-05-27 7:34 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FC09ECC.5050206@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.