all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* EMACS_INT vs int for range checking
@ 2012-05-26  9:13 Paul Eggert
  2012-05-26 10:11 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2012-05-26  9:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs Development

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-27  7:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-26  9:13 EMACS_INT vs int for range checking Paul Eggert
2012-05-26 10:11 ` Eli Zaretskii
2012-05-26 19:05   ` Paul Eggert
2012-05-27  6:19     ` Eli Zaretskii
2012-05-27  7:34       ` Paul Eggert

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.