-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
int::from_str("-1") == -253 and other bugs #1102
Comments
mbrubeck
added a commit
to mbrubeck/rust
that referenced
this issue
Oct 30, 2011
brson
pushed a commit
that referenced
this issue
Oct 30, 2011
mbrubeck
added a commit
to mbrubeck/rust
that referenced
this issue
Oct 31, 2011
Without this fix, int::parse_buf and uint::parse_buf return incorrect results for any strings that contain non-numeric characters. Fixes rust-lang#1102.
bjorn3
added a commit
to bjorn3/rust
that referenced
this issue
Nov 3, 2020
coastalwhite
pushed a commit
to coastalwhite/rust
that referenced
this issue
Aug 5, 2023
celinval
pushed a commit
to celinval/rust-dev
that referenced
this issue
Jun 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
int::from_str returns bad results for strings that start with "-" signs, because it adjust its character position in the wrong direction. Examples:
It also returns bad results for any strings with non-numeric characters:
In addition, int::parse_buf is broken for any radix greater than 10:
Most or all of the same bugs apply to the
uint
module too.While we're here, would it be better for these methods to return option::t instead of failing on bad input?
The text was updated successfully, but these errors were encountered: