Tcl Source Code

View Ticket
Login
Ticket UUID: dd14ad78248c6b4930fad6de2995cb86cab926e8
Title: String is integer/wide do not seem to check the correct ranges
Type: Bug Version: >= 8.5
Submitter: apnadkarni Created on: 2015-11-09 10:14:44
Subsystem: 11. Conversions from String Assigned To: dgp
Priority: 7 High Severity: Important
Status: Closed Last Modified: 2016-08-23 13:46:54
Resolution: Invalid Closed By: dkf
    Closed on: 2016-08-23 13:46:54
Description:
% string is integer 2147483649
1
% expr {int(2147483649)}
-2147483647

% string is wide -9223372036854775809
1
% expr {wide(-9223372036854775809)}
9223372036854775807

Both those numbers do not fit in the respective 32/64 bit widths. Note that [string is] is supposed to check for range. For example,

% string is integer 21474836490
0

/Ashok
User Comments: dgp added on 2015-11-09 19:40:51:
Not a bug.  See TIP 297.

sebres added on 2015-11-09 11:18:53:
Agree. I believe the Tcl_GetWideIntFromObj works "wrong" in sense of "string is wideinteger" if the given object a bignum that can fit in a Tcl_WideInt, but it occurs sign independent!

So either inside StringIsCmd after executing of Tcl_GetWideIntFromObj it should check a sign of "original" bignum object.
Or we should change logic of Tcl_GetWideIntFromObj for bignum that can fit with invalid sign (I will prefer this, but it has serious impact).

I will increase a priority, because it can be an issue of Tcl_GetWideIntFromObj self (not a string issue only).