-
Notifications
You must be signed in to change notification settings - Fork 1.6k
lint for integer overflow, especially in release mode #12503
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
Comments
This seems to be covered by arithmetic_side_effects? |
|
arithmetic_side_effects is in the #![warn(clippy::arithmetic_side_effects)] // <-------------
#![allow(dead_code, unused_variables)]
fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let s = (s.trim().parse::<u8>().unwrap()) * 3;
}
|
Unfortunately
But probably it doesn't make sense to use this ticket as a tracking issue for problems with this lint; it shoud be closed. |
What it does
Rust panics for integer overflow in debug mode, but it will wrap around any integers in release mode, aka, when
--release
parameter is added for cargo.Advantage
No response
Drawbacks
No response
Example
It accepts user input then multiply the accepted integer by 3, may wrap around when multiply by 3.
The text was updated successfully, but these errors were encountered: