Tcl Source Code

View Ticket
Login
Ticket UUID: 2b6a4fa5ed30b44364b1cb31aa8aa574e9b003a0
Title: Tcl_ObjPrintf does not print wide ints with %ld
Type: Bug Version: 8.6.4
Submitter: apnadkarni Created on: 2015-12-09 03:54:09
Subsystem: 10. Objects Assigned To: dgp
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-04-07 14:57:15
Resolution: Fixed Closed By: dgp
    Closed on: 2018-04-07 14:57:15
Description:
Using the %ld specifier and passing in a wide int results in printing of only the low 32 bits (possibly the high 32 on big endian machines). The man page says:

"The formatting is done with the same core formatting engine used by Tcl_Format. This means the set of supported conversion specifiers is that of the format command..."

Both format and Tcl_Format handle %ld correctly which implies Tcl_ObjPrintf should as well but it does not.
User Comments: dgp added on 2018-04-07 14:57:15:

TIP 476 corrects this in Tcl 8.7.

dgp added on 2015-12-09 17:50:44:
This is tricky because the *Printf formatting specs
control memory access issues as well as formatting,
so you need 4 distinctions to cover the cases (read
the argument as int, long, Tcl_WideInt, mp_int), and
the [format] engine only supplies 3.  What's been
done up to now is to make *Printf so what the printf()
system calls do.

dgp added on 2015-12-09 17:43:59:
http://core.tcl.tk/tcl/artifact/24d36182565d6b2b?ln=2586