summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-03-25 16:58:38 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-03-25 16:58:38 (GMT)
commit773e53fd316eb916b885120ed4960368abec9acd (patch)
tree194f24f0e654cc000fb057f5284f806d07634e7d /generic
parentd6c8b1f344c1864f243a235fd35b19b5277c2d1f (diff)
downloadtcl-773e53fd316eb916b885120ed4960368abec9acd.zip
tcl-773e53fd316eb916b885120ed4960368abec9acd.tar.gz
tcl-773e53fd316eb916b885120ed4960368abec9acd.tar.bz2
* generic/tclExecute.c: Corrections to INST_EXPON detection of
overflow to use mp_int calculations.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 9b1f26e..65da821 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.231 2006/03/24 19:05:40 kennykb Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.232 2006/03/25 16:58:38 dgp Exp $
*/
#include "tclInt.h"
@@ -4715,7 +4715,8 @@ TclExecuteByteCode(
wResult -= 1;
}
break;
- case INST_EXPON:
+ case INST_EXPON: {
+ int wasNegative;
if (w2 & 1) {
wResult = w1;
} else {
@@ -4724,21 +4725,24 @@ TclExecuteByteCode(
w1 *= w1;
w2 /= 2;
for (; w2>Tcl_LongAsWide(1) ; w1*=w1,w2/=2) {
+ wasNegative = (wResult < 0);
if (w1 < 0) {
goto overflow;
}
if (w2 & 1) {
wResult *= w1;
- if (wResult < 0) {
+ if (wasNegative != (wResult < 0)) {
goto overflow;
}
}
}
+ wasNegative = (wResult < 0);
wResult *= w1;
- if (wResult < 0) {
+ if (wasNegative != (wResult < 0)) {
goto overflow;
}
break;
+ }
default:
/* Unused, here to silence compiler warning. */
wResult = 0;