summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-08-20 16:52:55 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-08-20 16:52:55 (GMT)
commit835252ce9b5e69bf41e470277be070640f02422b (patch)
tree68ec1e271971ddf28fd21ce761fd8812d90f8d73 /generic/tclExecute.c
parenta7fd173f41040ffdcd5acefcf5e8965d1250d8c7 (diff)
downloadtcl-835252ce9b5e69bf41e470277be070640f02422b.zip
tcl-835252ce9b5e69bf41e470277be070640f02422b.tar.gz
tcl-835252ce9b5e69bf41e470277be070640f02422b.tar.bz2
* generic/tclExecute.c (INST_SUB): fix usage of the new macro for
overflow detection in sums, adapt to subtraction. Lenghty comment added.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 6bab480..3a870e0 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.318 2007/08/19 22:50:03 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.319 2007/08/20 16:52:57 msofer Exp $
*/
#include "tclInt.h"
@@ -5300,10 +5300,17 @@ TclExecuteByteCode(
#endif
{
/*
- * Must check for overflow.
+ * Must check for overflow. The macro tests for overflows
+ * in sums by looking at the sign bits. As we have a
+ * subtraction here, we are adding -w2. As -w2 could in turn
+ * overflow, we test with ~w2 instead: it has the opposite
+ * sign bit to w2 so it does the job. Note that the only
+ * "bad" case (w2==0) is irrelevant for this macro, as in
+ * that case w1 and wResult have the same sign and there
+ * is no overflow anyway.
*/
- if (Overflowing(w1, w2, wResult)) {
+ if (Overflowing(w1, ~w2, wResult)) {
goto overflow;
}
}