[perl #46623] [TODO] [C] Check for bigint overflow in new_from_string()
Andrew Whitworth via RT
parrotbug-followup at parrotcode.org
Mon Feb 2 20:33:01 UTC 2009
On Mon Oct 22 05:06:17 2007, pcoch wrote:
> In src/pmc/integer.pmc:new_from_string() there is the todo item:
>
> /* TODO bigint overflow */
>
> I *believe* this means to check for possible big integer overflow
issues at
> this point in the code; especially before calling string_to_int().
Note: "new_from_string()" now appears to be called "instantiate_str()".
string_to_int doesn't perform any checking to determine if the string it
is converting overflows. Here's what needs to happen:
1) string_to_int needs to be modified slightly to check for overflow
internally, and return PARROT_INTVAL_MAX if it's going to overflow
2) instantiate_str here needs to check for PARROT_INTVAL_MAX, and handle
that appropriately.
Of course, we need to figure out what "handle that appropriately" means.
Do we want to morph immediately to a BigInt, or do we want to throw an
exception?
Also, is it going to break anything if string_to_int saturates to
PARROT_INTVAL_MAX instead of allowing it to overflow and fall back to
platform-dependent overflow behavior? Most platforms I know will
rollover here, which will give a nonsensical result in almost all cases.
I assume this is not what we want?
--
Andrew Whitworth
a.k.a Whiteknight
More information about the parrot-dev
mailing list