Skip to content

Unchecked array indices with --emit=metadata #51491

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

Open
leonardo-m opened this issue Jun 11, 2018 · 2 comments
Open

Unchecked array indices with --emit=metadata #51491

leonardo-m opened this issue Jun 11, 2018 · 2 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

leonardo-m commented Jun 11, 2018

This is a spinoff of Issue #51308.

Using:

rustc 1.28.0-nightly (a805a2a5e 2018-06-10)
binary: rustc
commit-hash: a805a2a5ebba2802f432d79874e59c24e398f82a
commit-date: 2018-06-10
host: x86_64-pc-windows-gnu
release: 1.28.0-nightly
LLVM version: 6.0

On this code:

fn main() {
    let a: [i32; 1] = [0; 1];
    a[1];
}

Compiling with:

rustc test.rs

I get:

error: index out of bounds: the len is 1 but the index is 1
 --> test.rs:3:5
  |
3 |     a[1];
  |     ^^^^
  |
  = note: #[deny(const_err)] on by default

Compiling with rustc --emit=metadata test.rs I get no errors.

@oli-obk oli-obk added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. labels Jun 18, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jun 18, 2018

These checks happen in the mir_optimized query (more specifically, in the const prop pass). We might need to move that pass to an earlier query

@Enselic
Copy link
Member

Enselic commented Jul 24, 2023

Still reproducible with Rust 1.71.

@rustbot label T-compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants