Skip to content

ICE on extremely large arrays #49230

Closed
Closed
@3442853561

Description

@3442853561

When I test this program with cargo test:

struct Bar(Vec<u8>);

impl Bar {
    fn new(values: &[u8]) -> Self {
        Bar(values.into())
    }
    fn get(&self, index: usize) -> u8 {
        self.0[index]
    }
}


#[test]
fn test() {
    let foo = Bar::new(&[0u8; 4294967295]);
    assert_eq!(foo.get(1), 0);
}

fn main() {
    println!("hello world");
}

I got this:

C:\...\test>cargo test
   Compiling foo v0.1.0 (file:///C:/.../test)
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (d6b06c63a 2017-11-09) running on i686-pc-windows-gnu

thread 'rustc' panicked at 'capacity overflow', src\libcore\option.rs:839:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `foo`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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