Artifacts Associated With Ticket 219223
Ticket change [59801c8edf] (rid 117989) by nobody on 2000-10-26 05:03:48:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 4087 Bug Version: 8.3b2 SubmitDate: '2000-01-26' LastModified: '2000-04-09' Severity: SER Status: Assigned Submitter: techsupp ChangedBy: hobbs RelatedBugIDs: 653 OS: Solaris OSVersion: Solaris 7 64 bit Machine: Ultra Enterprise 4500 FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: Matthew Finch ReproducibleScript: If I compile tcl8.3b2 in 64 bit mode on Solaris 7 using -xarch=v9 then perform the following I get.... # ./tclsh % format %X 4294967290 integer value too large to represent as non-long integer % If I compile tcl8.3b2 in 32 bit mode on Solaris 7 then perform the following I get... # ./tclsh % format %X 4294967290 FFFFFFFA % The problem is relates to the casting in Tcl_GetIntFromObj() if (((long)((int)l)) == l) { *intPtr = (int)objPtr->internalRep.longValue; return TCL_OK; } The results should be the same. ObservedBehavior: If I compile tcl8.3b2 in 64 bit mode on Solaris 7 using -xarch=v9 then perform the following I get.... # ./tclsh % format %X 4294967290 integer value too large to represent as non-long integer % DesiredBehavior: I expect to see the same behaviour as when I compiled tclsh on Solaris 7 in 32 bit mode e.g # ./tclsh % format %X 4294967290 FFFFFFFA % Actually, there is some level of correctness here. The number the user is using is just -6 as far as Tcl is concerned on a 32bit system. When there are true longs, then Tcl handles the number properly in certain contexts. However, format currently isn't one of them. This should be revisited in 8.4 to look at expanding the use of Tcl_GetLongFromObj, which would solve the problem here. We just need to make sure it won't confuse something else down the chain that will choke on the long value. -- 04/09/2000 hobbs - foundin initialized to: "obsolete: 8.3b2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "81. Bundled Packages"
- title initialized to:
64 bit format command behaves differently to the 32bit forma
- type initialized to: "Bug"
Ticket change [7fe7540d01] (rid 97641) by kennykb on 2000-12-12 00:34:28:
- icomment:
Patch #102663 (quite inadvertently) updates the Tcl test suite with a regression test for this problem. There was a bug on 32-bit platforms as well: negative integers [format]ted with %x or %o could not be recovered by [scan]ning them with %x or %o. The [scan] would not return an error but would silently replace them with MAX_INT. The fix for this bug includes a test case that tries to do complementary [format] and [scan] of -1, MAX_INT, and MIN_INT; this test case fails on 64-bit platforms because it trips over this issue with [format].
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment:
Ticket change [a54a73800e] (rid 110348) by dkf on 2001-02-07 23:14:49:
- subsystem changed to: "16. Commands A-H"
Ticket change [f9e47c184b] (rid 91774) by dkf on 2001-02-15 23:29:01:
- assignee changed to: "dkf"
Ticket change [a4aa9577d6] (rid 110243) by dkf on 2001-03-19 18:09:26:
- icomment:
Logged In: YES user_id=79902 I am developing a patch that fixes this by allowing the use of the 'l' specifier in format and scan.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [aea3bd6170] (rid 101673) by dkf on 2001-03-19 20:06:48:
- icomment:
Logged In: YES user_id=79902 Trying to upload a patch to fix this...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Add attachment "format64.patch" [087ea4975a] (rid 89569) by dkf on 2001-03-19 20:06:49.
Ticket change [b69045954e] (rid 125442) by dkf on 2001-03-19 20:06:49:
- icomment:
File Added - 4393: format64.patch
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [74c78c3d42] (rid 105272) by dkf on 2001-03-19 20:07:35:
- icomment:
Logged In: YES user_id=79902 Please review...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [4c48b0f0e2] (rid 126858) by dgp on 2001-03-22 07:32:19:
- icomment:
Logged In: YES user_id=80530 I confirm that this patch adds the ability to avoid this bug. It does so by adding new features, though, so perhaps a short TIP is in order. I'm troubled by the non-Portability of test format-1.13. Neither of these results really makes sense to me: # 32-bit platform: % format %d 4294967290 -6 # 64-bit platform: % format %d 4294967290 integer value too large to represent as non-long integer I understand what's going on, but why should the Tcl script level claim that -6 == 4294967290 anywhere? And if it claims such nonsense anywhere, why not everywhere? What I see above is the very platforms which *can* handle the integer value 4294967290 are refusing to do so and throwing an error instead, and those that *can't* are silently converting it into -6 without throwing an error. I suppose if we open the topic up a bit to a discussion of how Tcl ought to be handling integer values at the script level, then a TIP is definitely in order. - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [bfe3cffa98] (rid 102324) by andreas_kupries on 2001-08-21 00:44:45:
- icomment:
Logged In: YES user_id=75003 There are two errors in Tcllib modules which seem to result from the problem reported here: http://sourceforge.net/tracker/index.php? func=detail&aid=446997&group_id=12883&atid=112883 http://sourceforge.net/tracker/index.php? func=detail&aid=447037&group_id=12883&atid=112883
- login: "andreas_kupries"
- mimetype: "text/plain"
- priority changed to: "7 High"
- username: "andreas_kupries"
- icomment:
Ticket change [360720870f] (rid 107047) by dgp on 2001-09-20 23:36:54:
- icomment:
Logged In: YES user_id=80530 OK, commits to both HEAD and core-8-3-1-branch on 2001-09-19 have fixed this, sort of. The reported error is corrected: % format %X 4294967290 FFFFFFFA works on both 32-bit and 64-bit platforms. However, the change also has this effect: % format %d 4294967290 -6 on *both* 32-bit and 64-bit platforms. If this behavior is to be kept, then we need to document in the format(n) page that %d formatting as a signed decimal string places its sign boundary at the range of a signed 32-bit integer.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [712a2969a4] (rid 100625) by dkf on 2001-09-21 16:17:05:
- icomment:
Logged In: YES user_id=79902 This was why I'd not changed it previously. This issue will need resolving as part of the 32/64 cleanup...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [abfce9ae98] (rid 101215) by dkf on 2002-02-16 04:24:01:
- closedate changed to: "2002-02-15T21:24:01"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 Is this fixed now? I *think* so, but I'm not sure...
- login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- username: "dkf"
Ticket change [6ace64a4d9] (rid 128218) by dgp on 2002-02-16 05:03:48:
- icomment:
Logged In: YES user_id=80530 No. There are still problems here. As noted before, we need documentation so folks are not surprised by this: % format %d 4294967290 -6 Make it explicit that signed 32-bit values are used unless the 'l' modifier is added: % format %ld 4294967290 4294967290 Also in format.n, point [3] of the last section says that the 'l' modifier is ignored. That is clearly no longer true. Getting to the actual bug, on a 64-bit Linux-Alpha: % format %d 4294967290 -6 % format %ld 4294967290 -6 so things are not consistent. I think the intent of TIP 72 was that there be consistent results on 32- and 64-bit platforms.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Remind"
- status changed to: "Open"
- username: "dgp"
- icomment:
Ticket change [a080a6884e] (rid 96826) by dkf on 2002-02-18 17:25:43:
- icomment:
Logged In: YES user_id=79902 Drat, missed a change in a manpage! Don't know what's up on 64-bit Linux-Alpha, but the problem might be that 'int' is 64 bits wide there (fuzzy memory or hearsay.) Will need to see if I can duplicate on 64-bit Solaris-SPARC...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [ec85022ce5] (rid 103720) by dkf on 2002-02-18 20:51:55:
- icomment:
Logged In: YES user_id=79902 Hmm. Can't duplicate the behaviour on Solaris/SPARC at all...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [80cd1d7ef5] (rid 116932) by dkf on 2002-02-18 21:02:32:
- icomment:
Logged In: YES user_id=79902 What is UINT_MAX on Linux/Alpha? I suspect even more strongly that the problem is that that is that sizeof(int)==sizeof(long), and since that's the case, bodging in a fix is easy; the hard bit will be ensuring that it doesn't cause masses of warnings, and stopping people who think they know what they are doing from fiddling with it.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [f6e03252d6] (rid 130390) by kennykb on 2002-02-19 06:04:55:
- icomment:
Logged In: YES user_id=99768 dgp says that sizeof(int) == 4, while sizeof(long) == sizeof(void*) == 8. UINT_MAX is 0xffffffff. The problem is that 0xfffffffa < UINT_MAX. The test at line 2108 of tclCmdAH.c reads: if ((unsigned long) intValue > UINT_MAX) This test detects that 0xfffffffa can be formatted with %d instead of %ld. It cannot. In any case, the code at line 2211: sprintf(dst, newFormat, intValue); is surely not correct. The case that we're testing here gets there with "%d" in newFormat, but "intValue" is a long: that surely cannot be expected to work! - login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment:
Ticket change [4b3f93f89f] (rid 126668) by dkf on 2002-02-19 17:45:56:
- closedate changed to: "2002-02-19T10:45:56"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 OK, so I'll make the code always work with longs on 64-bit platforms, and the 'l' modifier will have no effect there. This seems to be what the test suite expects (that %d works with long) so I'll make that the defined behaviour everywhere.
- login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dkf"