|
2004-09-11
| ||
| 05:39 | • Ticket [991371ffff] format problem with wide ints status still Closed with 7... artifact: c9d5bcc3dc user: dkf | |
| 05:39 | • Closed ticket [991371ffff]. artifact: a91d1f8f3f user: dkf | |
|
2004-08-04
| ||
| 03:37 | • Ticket [991371ffff]: 4 changes artifact: 4982e38e9e user: dkf | |
|
2004-07-16
| ||
| 12:21 | • Ticket [991371ffff]: 4 changes artifact: 4b4fec1e69 user: bgriffin | |
| 11:31 | • Ticket [991371ffff]: 4 changes artifact: f4a99c1150 user: hobbs | |
| 05:22 | • Ticket [991371ffff]: 4 changes artifact: f01575c434 user: dgp | |
| 04:51 | • Ticket [991371ffff]: 4 changes artifact: c7bef9744e user: hobbs | |
| 04:47 | • Ticket [991371ffff]: 4 changes artifact: e62944ba7d user: dgp | |
| 01:34 | • Ticket [991371ffff]: 5 changes artifact: 959bf6ab95 user: hobbs | |
|
2004-07-15
| ||
| 13:01 | • Ticket [991371ffff]: 4 changes artifact: 9ce4a0c070 user: bgriffin | |
| 05:59 | • New ticket [991371ffff]. artifact: 1df2c999f4 user: bgriffin | |
format problem with wide ints
Closed / Fixed991371ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-07-15 05:59:38
The format command errors out on %d of a wide int, but
than converts the wide int to int so that subsequent
format works without error.
Place the following in a file "format_bug.tcl":
set x [file size format_bug.tcl]
puts stdout "First format:"
if {[catch {format "%d bytes" $x} res]} {
puts stdout "Error: $res\nTrace back: $errorInfo"
} else {
puts stdout $res
}
puts stdout "Second format:"
if {[catch {format "%d bytes" $x} res]} {
puts stdout "Error: $res\nTrace back: $errorInfo"
} else {
puts stdout $res
}
Running the above code produces:
First format:
Error:
Trace back:
while executing
"format "%d bytes" $x"
Second format:
337 bytes
bgriffinplain2004-07-15 13:01:14
Logged In: YES user_id=22949 I forgot to mention: This fails on 64-bit Solaris.
hobbsplain2004-07-16 01:34:02
Logged In: YES user_id=72656 This appears to be related to bug 699060 fixed in the 8.5 head. It needs to be backported as it clearly breaks on 8.4 (not all 64-bit plats, but something is wrong).
dgpplain2004-07-16 04:47:31
Logged In: YES user_id=80530 Report 699060 claims the fix went into Tcl 8.4.3 .
hobbsplain2004-07-16 04:51:38
Logged In: YES user_id=72656 It may, and 702622 appears to be in 8.4 as well, but that doesn't discount the fact that %[duxX] have different code between 8.4 and the head - there are no ChangeLog docs to really indicate why they should be so separate.
dgpplain2004-07-16 05:22:19
Logged In: YES user_id=80530 Is this bug present in Tcl 8.4.2 ?
hobbsplain2004-07-16 11:31:53
Logged In: YES
user_id=72656
I found that this:
- if (wideValue>ULONG_MAX || wideValue<LONG_MIN) {
+ if (wideValue>LONG_MAX || wideValue<LONG_MIN) {
at line 2209 of tclCmdAH.c:Tcl_FormatObjCmd made it work on
Solaris-64, which indicates a sign extension bug in the
compiler.
Note that the above fix isn't actually correct code for this
case (although I wonder whether we should be mingling
unsigned checks for %d as well as the %[uoxX] this case covers).
Also, a shorter test case is:
et x [expr {wide(1)}]
set code [catch {format "%d bytes" $x} res]
puts "1st format ($code): $res"
set code [catch {format "%d bytes" $x} res]
puts "2nd format ($code): $res"
bgriffinplain2004-07-16 12:21:53
Logged In: YES user_id=22949 Compiler bugs aside, I question why isn't %d automatically promoted to %ld if/when Obj is a Wide int? Otherwise, tcl programmers are forced to concern themselves with type in a "typeless" language. This doesn't seem right to me. See, if the wide int was actually indeed larger than LONG_MAX (>32- bits) then an error would have been produced legitimately. This means at the tcl level one must concern themselves with %d vs %ld. But these notions were invented to deal with different types (int vs long). Tcl is not supposed to be "typed".
dkfplain2004-08-04 03:37:25
Logged In: YES user_id=79902 There are altogether too many ways for me to list right now in which I'm not satisfied with the current handling of 64-bit values on 32-bit platforms. This is *not* the most surprising of them. :^(
dkf Closed ticket [991371ffff].
[History diff]2004-09-11 05:39:07
dkfplain2004-09-11 05:39:08
Logged In: YES user_id=79902 The fix for Bug 868489 seems to have cleared this up as well (or at least it all works for me now I've patched that.)
Log in (anonymous is fine) to add a comment.