Message29161
Logged In: YES
user_id=42444
Yes, this is a duplicate of 1521726.
The compiler people's answer is correct, and mystrtoul.c is
incorrect. LONG_MIN has been in C since C90, so should be
safe, but its value may not always be what you expect.
However, the code breakage is worse that just that test, and
there are the following 3 cases of undefined behaviour:
1) Casting and unsigned long to long above LONG_MAX.
2) That test.
3) result = -result.
The fix should be to make result unsigned long, and check
the range BEFORE any conversion. Nothing else is safe.
It is a matter of taste whether to include a fiddle for the
number that can be held only when negated - I wouldn't, and
would let that number be converted to a Python long, but
others might disagree.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:41:20 | admin | link | issue1521947 messages |
2007-08-23 14:41:20 | admin | create | |
|