Skip to content

Unchecked array indices with --emit=metadata #51491

Open
@leonardo-m

Description

@leonardo-m

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions