Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d8077394467b4836ef8e861f7b831b4384476e8e
Ticket: 526717ffffffffffffffffffffffffffffffffff
list indexing corrupts wide ints
User & Date: dgp on 2002-03-07 00:33:14
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    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
    
  4. foundin changed to: "obsolete: 8.4a5"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dgp"
  9. subsystem changed to: "10. Objects"
  10. title changed to: "list indexing corrupts wide ints"
  11. type changed to: "Bug"