diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-08-25 20:34:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-08-25 20:34:32 (GMT) |
commit | 4fc5e6946cda507e391013d7f34cf510e07012f2 (patch) | |
tree | f34f5a2c4657d58fcb8a3199ab0dd399dfdefc81 | |
parent | 3c97d09460dbe4d2b4eddbbca87efa5f9a82be72 (diff) | |
parent | a951fd16e79634a5967b32b281e69c2ec6cd9d8e (diff) | |
download | tcl-4fc5e6946cda507e391013d7f34cf510e07012f2.zip tcl-4fc5e6946cda507e391013d7f34cf510e07012f2.tar.gz tcl-4fc5e6946cda507e391013d7f34cf510e07012f2.tar.bz2 |
Fix [920e393634]: expr {7244019458077122840 << 1}. Some more long -> Tcl_WideInt fixes in comments
-rw-r--r-- | generic/tclExecute.c | 22 | ||||
-rw-r--r-- | tests/expr.test | 1 |
2 files changed, 12 insertions, 11 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 2b49b82..139d063 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3745,7 +3745,7 @@ TEBCresume( objResultPtr = objPtr; /* - * We know the sum value is outside the long range; + * We know the sum value is outside the Tcl_WideInt range; * use macro form that doesn't range test again. */ @@ -6084,9 +6084,9 @@ TEBCresume( if (w2 >= (Tcl_WideInt)(CHAR_BIT*sizeof(w1))) { /* * We assume that INT_MAX is much larger than the - * number of bits in a long. This is a pretty safe + * number of bits in a Tcl_WideInt. This is a pretty safe * assumption, given that the former is usually around - * 4e9 and the latter 32 or 64... + * 4e9 and the latter 64... */ TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr))); @@ -6100,7 +6100,7 @@ TEBCresume( } /* - * Handle shifts within the native long range. + * Handle shifts within the native Tcl_WideInt range. */ wResult = w1 >> ((int) w2); @@ -6146,12 +6146,12 @@ TEBCresume( int shift = (int) w2; /* - * Handle shifts within the native long range. + * Handle shifts within the native Tcl_WideInt range. */ if (((size_t)shift < CHAR_BIT*sizeof(w1)) && !((w1>0 ? w1 : ~w1) & - -(1UL<<(CHAR_BIT*sizeof(w1) - 1 - shift)))) { + -((Tcl_WideUInt)1<<(CHAR_BIT*sizeof(w1) - 1 - shift)))) { wResult = (Tcl_WideUInt)w1 << shift; goto wideResultOfArithmetic; } @@ -6251,7 +6251,7 @@ TEBCresume( #endif /* - * Handle (long,long) arithmetic as best we can without going out to + * Handle Tcl_WideInt arithmetic as best we can without going out to * an external function. */ @@ -8285,8 +8285,8 @@ ExecuteExtendedBinaryMathOp( mp_int big1, big2, bigResult, bigRemainder; Tcl_Obj *objResultPtr; int invalid, zero; - long shift; - mp_err err; + int shift; + mp_err err; (void) GetNumberFromObj(NULL, valuePtr, &ptr1, &type1); (void) GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2); @@ -8685,7 +8685,7 @@ ExecuteExtendedBinaryMathOp( * We refuse to accept exponent arguments that exceed one mp_digit * which means the max exponent value is 2**28-1 = 0x0FFFFFFF = * 268435455, which fits into a signed 32 bit int which is within the - * range of the long int type. This means any numeric Tcl_Obj value + * range of the Tcl_WideInt type. This means any numeric Tcl_Obj value * not using TCL_NUMBER_INT type must hold a value larger than we * accept. */ @@ -9083,7 +9083,7 @@ TclCompareTwoNumbers( d1 = (double) w1; /* - * If the double has a fractional part, or if the long can be + * If the double has a fractional part, or if the Tcl_WideInt can be * converted to double without loss of precision, then compare as * doubles. */ diff --git a/tests/expr.test b/tests/expr.test index 6b7dbf5..2c1dc21 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -1429,6 +1429,7 @@ test expr-24.9 {expr edge cases; shifting} {expr 5>>32} 0 test expr-24.10 {INST_LSHIFT: Bug 1567222} {expr 500000000000000<<28} 134217728000000000000000 test expr-24.11 {INST_LSHIFT: Bug 84a5355235} {expr -549755813888>>32} -128 +test expr-24.12 {INST_LSHIFT: Bug 920e393634} {expr 7244019458077122840<<1} 14488038916154245680 # List membership tests test expr-25.1 {'in' operator} {expr {"a" in "a b c"}} 1 |