Skip to content
Tcl Source Code View Ticket
Login

View Ticket

mathfunc::int incompatibility between 8.6 and 8.7

Closed / Invalid6dccab47cdf686a0c33c73c4f11a53e9a677edc9Created 4 years agoUpdated 4 years ago
Descriptionmarkdown2023-04-09 08:24:13

In 8.6,

% package require Tcl
8.6.13
% expr {int(0xffffffff)}
-1
% tcl::mathfunc::int 0xffffffff
-1

In 8.7,

% package require Tcl
8.7a6
% expr {int(0xffffffff)}
4294967295
% tcl::mathfunc::int 0xffffffff
0xffffffff

As 8.7 should be fully compatible with 8.6, I would expect result would have been the same in the two cases.

chrstphrchvzwiki2023-04-10 04:41:12

I have been under the impression that 8.7 will only be ABI compatible with 8.6, and not necessarily script compatible. I believe this particular change is due to TIP 514. If one needs to perform signed truncation to a specific width then I would think they are better off using functions like:

proc to_signed_32bit {x} {expr {(($x + 0x80000000) & 0xffffffff) - 0x80000000}}

and that if they really need to know sizeof(long) then they can check $tcl_platform(wordSize).

apnadkarniplain2023-04-11 16:59:29
I'm pretty sure 8.7 is expected to be compatible with 8.6 at the script level as well. But I could be wrong.

I've never had a previous use for this function but ran into it when interactively conjuring (or trying to) specific internal representations for testing purposes from script level.

/Ashok
jan.nijtmanswiki2023-04-13 15:49:33

It's described in TIP #514, so not a bug.

Log in (anonymous is fine) to add a comment.