Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2023-05-01
12:19 • Closed ticket [ad9361fd20]: string end-relative calculation broken for large ind... artifact: 1d51860d2e user: apnadkarni
12:16
Tests for [ad9361fd20] check-in: ed26748c6b user: apnadkarni tags: trunk, main
2023-04-12
16:19 • Ticket [ad9361fd20] string end-relative calculation broken for large indices... artifact: 38b0f5f509 user: apnadkarni
2023-03-25
10:45 • Ticket [ad9361fd20]: 4 changes artifact: b4feea931a user: apnadkarni
2023-03-24
18:58 • New ticket [ad9361fd20]. artifact: a0785b419c user: apnadkarni

string end-relative calculation broken for large indices

Closed / Fixedad9361fd20f0b9c5c94d67f3c2b0450005d27250Created 4 years agoUpdated 4 years ago
Descriptionmarkdown2023-03-24 18:58:04
% 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.

Referenced by1
apnadkarniplain2023-03-25 10:45:45
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
apnadkarni Ticket [ad9361fd20]: 3 changes [History diff]2023-04-12 16:19:32
apnadkarniplain2023-05-01 12:19:00
Fixed somewhere in the TIP 660 commits. Added tests in [ed26748c6b]
Log in (anonymous is fine) to add a comment.