|
2019-07-05
| ||
| 14:37 | • Ticket [aaa02c55b9] lrange with huge index, weird results status still Close... artifact: 42ebe0cdf4 user: dgp | |
| 12:28 | • Closed ticket [aaa02c55b9]. artifact: 68c217f17a user: jan.nijtmans | |
|
2017-11-03
| ||
| 12:26 | • Ticket [aaa02c55b9]: 3 changes artifact: 7d1480d1a7 user: jan.nijtmans | |
| 12:01 | • Ticket [aaa02c55b9]: 3 changes artifact: 25607905d5 user: dgp | |
| 10:42 | • Ticket [aaa02c55b9]: 3 changes artifact: f047f8d0ea user: jan.nijtmans | |
| 09:43 | • Ticket [aaa02c55b9]: 3 changes artifact: e92c8e844d user: sebres | |
| 08:56 | • New ticket [aaa02c55b9]. artifact: d2b7338466 user: jan.nijtmans | |
lrange with huge index, weird results
Closed / Fixedaaa02c55b9cb7b62c39bb02a7631ccd88fd00295Created 9 years agoUpdated 7 years ago
Descriptionwiki2017-11-03 08:56:53
% lrange {a b c} 15 end
% lrange {a b c} 2147483649 end
a b c
This is strange. First result is as expected, second should give an empty list as result as well.
sebresplain2017-11-03 09:43:47
Hi Jan,
as you certainly know, the index is signed integer here,
thus just do `expr {int(2147483649)}` -> -2147483647 :)
The options:
- Rather the index should be retrieved as INT_MAX in such cases (which could be also too dangerous e. g. will unexpectedly return something for very large lists);
- Or the API for indices should be rewritten to wide-int (incompatible then);
- Or the error "integer too large" should be thrown (which will be certainly annoying sometimes).
jan.nijtmanswiki2017-11-03 10:42:01
First shot for proposed solution in branch "bug-aaa02c55b9". For Tcl8 I would like to clamp the values between INT_MIN and INT_MAX. I don't think that's too dangerous, since we can allready use INT_MAX in scripts directly: We must already handle that, anywhere we are failing to do so is a bug.
For Tcl9, I would like to modify the API (which is just internal, so that's OK) to use "size_t *" in stead of "int *". Then we can clamp between -1 (represented as (size_t)-1) and LLONG_MAX (actually (size_t)-2), which is sufficiently for all future memory limitations. ;-)
TIP is in preparation (sofar only in my mind yet ...)
dgpplain2017-11-03 12:01:02
See also TIP 297.
jan.nijtmans Ticket [aaa02c55b9]: 3 changes
[History diff]2017-11-03 12:26:29
jan.nijtmansplain2019-07-05 12:28:09
Since TIP #297 is in the core now, everything as expected now! Closing.
dgpplain2019-07-05 14:37:49
Just for the record, the behavior change was approved in TIP 502.
Log in (anonymous is fine) to add a comment.