From 835252ce9b5e69bf41e470277be070640f02422b Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Mon, 20 Aug 2007 16:52:55 +0000 Subject: * generic/tclExecute.c (INST_SUB): fix usage of the new macro for overflow detection in sums, adapt to subtraction. Lenghty comment added. --- ChangeLog | 6 ++++++ generic/tclExecute.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfe8eca..129b159 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-08-20 Miguel Sofer + + * generic/tclExecute.c (INST_SUB): fix usage of the new macro for + overflow detection in sums, adapt to subtraction. Lenghty comment + added. + 2007-08-19 Donal K. Fellows * generic/tclExecute.c (Overflowing, TclIncrObj, TclExecuteByteCode): 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; } } -- cgit v0.12