Overview
| Artifact ID: | dcf6b74d0ed15fec959bbd4f59242614bf1b611c |
|---|---|
| Ticket: | 2413689fffffffffffffffffffffffffffffffff
Bug in function s_mp_sqr() |
| User & Date: | kennykb on 2008-12-11 04:21:53 |
Changes
- icomment:
In this case, overflow appears impossible. It is important to remember that not all the bits of an mp_digit are actually used; the maximum value for an mp_digit is (1<<28)-1. So here I see that r (a 64-bit integer) is set to the product of two mp_digits (which is less than 2**56). It's subsequently doubled, and then two more mp_digits are added to it, so it winds up still less than 2**58 + 2**29. This is comfortably less than 2**63-1, the maximum size of an mp_word. Even if MP_31BIT is defined - which Tcl does not do - the result of this addition is at most 2**62 + 2**32, still less than 2**63-1. (Tcl does not define MP_31BIT because observed performance is better with the Comba multipliers, which are incompatible with that option.) Overflow would be possible if tommath used all 32 bits of an mp_digit. But it doesn't.
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"