Skip to content
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

out_of_bounds_indexing false positive #1668

Open
leonardo-m opened this issue Apr 9, 2017 · 0 comments
Open

out_of_bounds_indexing false positive #1668

leonardo-m opened this issue Apr 9, 2017 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on T-middle Type: Probably requires verifiying types

Comments

@leonardo-m
Copy link

leonardo-m commented Apr 9, 2017

This comes from a code reduction, so it's reasonable in its original context:

#![allow(unused_variables)]
fn main() {
    const N: usize = 1_000;
    let data = [0, 0, 0, 0];
    if N <= 4 {
        let result = data[N - 1];
    }
}
error: index out of bounds: the len is 4 but the index is 999
 --> src/main.rs:6:22
  |
6 |         let result = data[N - 1];
  |                      ^^^^^^^^^^^
  |
  = note: #[deny(const_err)] on by default
@mcarton mcarton added E-hard Call for participation: This a hard problem and requires more experience or effort to work on C-bug Category: Clippy is not doing the correct thing T-middle Type: Probably requires verifiying types labels Apr 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

2 participants