Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b4feea931a4891dd0f5457d0e89d18d39e98549a2b070e2cdb66a932e80be8c3
Ticket: ad9361fd20f0b9c5c94d67f3c2b0450005d27250
string end-relative calculation broken for large indices
User & Date: apnadkarni on 2023-03-25 10:45:45
Changes

  1. comment changed to:
    ```
    % string range [string insert [string repeat a 0x80000000] end-0x7fffffff X] 0 10
    Xaaaaaaaaaa
    ```
    
    I expected "aXaaa..."
    
    Along the same lines,
    
    ```
    % set s [string repeat a 0xffffffff]; string length $s
    4294967295
    % string index $s end-0xfffffffe
    a
    % string range $s end-0xfffffffe  end-0xfffffffe
      <- (empty string)
    ```
    
    `string index` gives correct result but not `string range`.
    
  2. icomment:
    Along the same lines,
    
    ```
    % string length [string range $s end-0x7fffffff end-0x7ffffffe]
    2147483664
    % string length [string range $s end-0x7ffffffd end-0x7ffffffd]
    1
    ```
    
    So the breakage seems to occur right at end-INT_MAX. I don't understand TclEncodeIndex well enough to tell if the bug is there or in the caller (range command)
    
    /Ashok
    
  3. login: "apnadkarni"
  4. mimetype: "text/plain"