From: SourceForge.net <no...@so...> - 2004-09-10 22:39:17
|
Bugs item #991371, was opened at 2004-07-15 06:59 Message generated for change (Comment added) made by dkf You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=991371&group_id=10894 Category: 16. Commands A-H Group: obsolete: 8.4.6 >Status: Closed >Resolution: Fixed Priority: 8 Submitted By: Brian Griffin (bgriffin) Assigned to: Donal K. Fellows (dkf) Summary: format problem with wide ints Initial Comment: 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 ---------------------------------------------------------------------- >Comment By: Donal K. Fellows (dkf) Date: 2004-09-10 23:39 Message: 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.) ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2004-08-03 21:37 Message: 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. :^( ---------------------------------------------------------------------- Comment By: Brian Griffin (bgriffin) Date: 2004-07-16 06:21 Message: 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". ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2004-07-16 05:31 Message: 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" ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2004-07-15 23:22 Message: Logged In: YES user_id=80530 Is this bug present in Tcl 8.4.2 ? ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2004-07-15 22:51 Message: 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. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2004-07-15 22:47 Message: Logged In: YES user_id=80530 Report 699060 claims the fix went into Tcl 8.4.3 . ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2004-07-15 19:34 Message: 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). ---------------------------------------------------------------------- Comment By: Brian Griffin (bgriffin) Date: 2004-07-15 07:01 Message: Logged In: YES user_id=22949 I forgot to mention: This fails on 64-bit Solaris. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=991371&group_id=10894 |