Use of a Tcl_WideInt as a list index will
shimmer it to an "int".
On a 32-bit platform:
% set index [expr {(wide(1)<<31) - 2}]
2147483646
% lindex {1 2 3} $index
% incr index
2147483647
% incr index
-2147483648
Contrast with:
% set index [expr {(wide(1)<<31) - 2}]
2147483646
% incr index
2147483647
% incr index
2147483648
It's worse on 64-bit platforms, where truncation
is to an "int" even though Tcl_Integers are really
longs:
% set index [expr {wide(1)<<32}]
4294967296
% lindex {1 2 3} $index
1
% incr index
4294967297
% lindex {1 2 3} $index
2
So here, we don't lose range on the index values,
but the indexing function "wraps around".
Suspect trouble in TclGetIntForIndex
Logged In: YES
user_id=80530
More generally, any place that
Tcl_GetIntFromObj is called should be considered
suspect.
Logged In: YES
user_id=79902
I supoose we could make Tcl_GetIntFromObj know about
wideobjs...
Logged In: YES
user_id=79902
TclGetIntForIndex really ought to use 'long' and 'long*' not
'int' and 'int*'...