#3757 TclGetNumberFromObj caller must save result

obsolete: 8.5a7
closed-fixed
Don Porter
5
2007-08-08
2007-08-08
Don Porter
No

For example:

% >> -0x8000000000000001 0x8000000000000000
0

Result should be -1. [>> $big $wide] is ok:

% >> -0x8000000000000001 0x7fffffffffffffff
-1

And clearly, shifting that -1 one more bit
ought to return -1 again, not 0.

Perhaps a clue... it's not always broken:

% >> -0x8000000000000000 0x8000000000000000
-1

Discussion

  • Don Porter
    Don Porter
    2007-08-08

    Logged In: YES
    user_id=80530
    Originator: YES

    ok that last "not broken" example
    actually fits in a wide.

     
  • Don Porter
    Don Porter
    2007-08-08

    Logged In: YES
    user_id=80530
    Originator: YES

    ok, problem is that when TclGetNumberFromObj()
    returns a bignum, it uses some temp space.
    The caller is supposed to save the result before
    calling again. The >> implementation code is
    not doing so, so when both arguments are bignums,
    we end up doing the operation with the second
    argument twice.

    This not only points the way to fixing this bug;
    it points out a whole project of code review to
    be done.

    Ick.

     
  • Don Porter
    Don Porter
    2007-08-08

    • summary: [>> $big1 $big2] incorrectly returns 0 --> TclGetNumberFromObj caller must save result
     
  • Don Porter
    Don Porter
    2007-08-08

     
    Attachments
  • Don Porter
    Don Porter
    2007-08-08

    Logged In: YES
    user_id=80530
    Originator: YES

    Ok, problem did not show up elsewhere.
    Here's the patch.

    File Added: 1770224.patch

     
  • Don Porter
    Don Porter
    2007-08-08

    • status: open --> closed-fixed
     
  • Don Porter
    Don Porter
    2007-08-08

    Logged In: YES
    user_id=80530
    Originator: YES

    committed.