-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from_str_radix
incorrectly parses out-of-range repeating constants...
#5770
Comments
The problem here is, I think, that the code that attempts to detect overflows only does so by detecting if the accumulator grows in the wrong direction, which only covers overflow for signed values. For it to detect this condition here, it also needs to check if the accumulator does not change, even though it should, or more generally, if it changes by a smaller value than it is supposed to. The reported behavior happens because, after the algorithm reads in the first 64
so it never sees that the value gets smaller |
…2^n numbers. A number like 0b1_1111_1111 == 511 would be parsed to Some(255u8) rather than None by from_str_common, since 255 * 2 + 1 == 255 (mod 256) so the overflow wasn't detected. Only applied to conversions where the radix was a power of 2, and where all digits repeated. Closes rust-lang#5770.
...when the radix is a power of 2. e.g. 100 1's is an invalid
u64
/i64
in any base, but for powers of 2 it gives a "correct" parse:outputs
The text was updated successfully, but these errors were encountered: