Skip to content
Tcl Source Code History Of Ticket 219223
Login

History Of Ticket 219223

Artifacts Associated With Ticket 219223

  1. Ticket change [59801c8edf] (rid 117989) by nobody on 2000-10-26 05:03:48:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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
      
    4. foundin initialized to: "obsolete: 8.3b2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "81. Bundled Packages"
    10. title initialized to:
      64 bit format command behaves differently to the 32bit forma
      
    11. type initialized to: "Bug"
  2. Ticket change [7fe7540d01] (rid 97641) by kennykb on 2000-12-12 00:34:28:

    1. 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].
      
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  3. Ticket change [a54a73800e] (rid 110348) by dkf on 2001-02-07 23:14:49:

    1. subsystem changed to: "16. Commands A-H"
  4. Ticket change [f9e47c184b] (rid 91774) by dkf on 2001-02-15 23:29:01:

    1. assignee changed to: "dkf"
  5. Ticket change [a4aa9577d6] (rid 110243) by dkf on 2001-03-19 18:09:26:

    1. 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.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [aea3bd6170] (rid 101673) by dkf on 2001-03-19 20:06:48:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Trying to upload a patch to fix this...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Add attachment "format64.patch" [087ea4975a] (rid 89569) by dkf on 2001-03-19 20:06:49.

  8. Ticket change [b69045954e] (rid 125442) by dkf on 2001-03-19 20:06:49:

    1. icomment:
      
      
      File Added - 4393: format64.patch
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [74c78c3d42] (rid 105272) by dkf on 2001-03-19 20:07:35:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Please review...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [4c48b0f0e2] (rid 126858) by dgp on 2001-03-22 07:32:19:

    1. 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.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [bfe3cffa98] (rid 102324) by andreas_kupries on 2001-08-21 00:44:45:

    1. 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
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. username: "andreas_kupries"
  12. Ticket change [360720870f] (rid 107047) by dgp on 2001-09-20 23:36:54:

    1. 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.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [712a2969a4] (rid 100625) by dkf on 2001-09-21 16:17:05:

    1. 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...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  14. Ticket change [abfce9ae98] (rid 101215) by dkf on 2002-02-16 04:24:01:

    1. closedate changed to: "2002-02-15T21:24:01"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      Is this fixed now?  I *think* so, but I'm not sure...
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Pending"
    8. username: "dkf"
  15. Ticket change [6ace64a4d9] (rid 128218) by dgp on 2002-02-16 05:03:48:

    1. 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. 
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. resolution changed to: "Remind"
    5. status changed to: "Open"
    6. username: "dgp"
  16. Ticket change [a080a6884e] (rid 96826) by dkf on 2002-02-18 17:25:43:

    1. 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...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  17. Ticket change [ec85022ce5] (rid 103720) by dkf on 2002-02-18 20:51:55:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm. Can't duplicate the behaviour on Solaris/SPARC at
      all...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  18. Ticket change [80cd1d7ef5] (rid 116932) by dkf on 2002-02-18 21:02:32:

    1. 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.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  19. Ticket change [f6e03252d6] (rid 130390) by kennykb on 2002-02-19 06:04:55:

    1. 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!
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  20. Ticket change [4b3f93f89f] (rid 126668) by dkf on 2002-02-19 17:45:56:

    1. closedate changed to: "2002-02-19T10:45:56"
    2. closer changed to: "dkf"
    3. 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.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"