Artifacts Associated With Ticket 47d66253c92197d3
Ticket change [bfc7fc72a9] (rid 136469) by anonymous on 2014-01-16 04:20:42:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
On 64bit system, the following code returns an unexpected result. (On Linux 32bit machine) % lsearch -sorted -integer [lsort -integer {0 2147483648}] 2147483648 0 => the value was found (On Linux 64bit machine) % lsearch -sorted -integer [lsort -integer {0 2147483648}] 2147483648 -1 => the value was not found - foundin initialized to: "8.4.20, 8.5.15, 8.6.1"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "17. Commands I-L"
- title initialized to: ""lsearch -sorted -integer" on 64bit system"
- type initialized to: "Bug"
Ticket change [3b111979b9] (rid 136470) by dgp on 2014-01-16 13:10:35:
- icomment:
[lsort -integer] is not portable. The interpretation it places on values varies with value of $tcl_platform(wordSize). For the same reason, you see: (On 32-bit system) % expr int(2147483648) -2147483648 (On 64-bit system) % expr int(2147483648) 2147483648
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [a5110c461a] (rid 136471) by dgp on 2014-01-16 13:19:05:
- icomment:
What this ticket seems to demonstrate, though, is that the meaning of "-integer" is inconsistent between [lsort] and [lsearch]. I confirm that. [lsort] uses Tcl_GetLongFromObj() and [lsearch] uses Tcl_GetIntFromObj(), so on systems where int and long are different (64-bit systems), they are inconsistent. That's an unfortunate mess. Whether it's a bug, and if so whether fixing it would solve more problems or create more new ones, I'll have to discuss with others. This is all a symptom of the messy stew of integer treatment in Tcl that history has delivered to us. See TIP 297.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e3a7978e58] (rid 136472) by dkf on 2014-01-16 15:34:30:
- assignee changed to: "dkf"
- icomment:
I'm tempted to say that the meaning of “<tt>-integer</tt>” that a reasonable user would expect would correspond to “anything that satisfies <tt>string is entier -strict</tt>”; limiting to signed-platform-word is… surprising.
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
Ticket change [ea14cc3bc8] (rid 138063) by dkf on 2014-05-11 10:43:25:
- login: "dkf"
- mimetype: "text/plain"
- priority changed to: "7 High"
Ticket change [c7356d7188] (rid 138064) by dkf on 2014-05-11 22:38:21:
- icomment:
However, a minimal first fix would be to switch to using a <tt>long</tt> and get rid of a <i>little bit</i> of the difference between 32-bit and 64-bit. <p> At least it's not something which is exposed in an API.
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
- icomment:
Ticket change [caea6eec5e] (rid 138069) by jan.nijtmans on 2014-05-12 13:09:29:
- icomment:
I agree with Donald that as first-fix the data-type could be up-scaled, but I would go one little step further: use Tcl_WideInt in both commands. See branch "bug-47d66253c9". That would resolve a related strange result (reproduced on win32): % lsearch -sorted -integer [lsort -integer {0 -2147483648}] 2147483648 0 2 % lsearch -sorted -integer [lsort -integer {0 2147483648}] -2147483648 0 Agreed? I don't see any unexpected side-effects from such a change. - login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [a839bb7fbe] (rid 138177) by jan.nijtmans on 2014-05-17 07:03:46:
- icomment:
Upgrade to Tcl_WideInt part now committed to trunk [f70fa16889]. I don't have any objections backporting this to core-8-5-branch, or enhance it further to work for bignums as well. Therefore keeping this open.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [64101b252d] (rid 207178) by jan.nijtmans on 2022-11-22 22:47:20:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2459906.44954809"
- closer changed to: "jan.nijtmans"
- icomment:
Dup of [3216010]. Fix already committed, so closing.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"