Skip to content

Assertion failed. Assigning static item using out of bounds index. #13701

Closed
@adam-frisby

Description

@adam-frisby

Attempting to compile the following code causes rustc to crash.

const VEC: [int, ..4] = [0, 1, 2, 3];

fn main() {
    static v: int = VEC[6];
}

Windows 8.1
rustc 0.11-pre-nightly (7d725a3 2014-04-21 23:01:39 -0700)
host: i686-pc-mingw32

C:\test.rs:1:1: 1:39 warning: code is never used: `VEC`, #[warn(dead_code)] on by default
C:\test.rs:1 static VEC: [int, ..4] = [0, 1, 2, 3];
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\test.rs:4:2: 4:25 warning: code is never used: `v`, #[warn(dead_code)] on by default
C:\test.rs:4    static v: int = VEC[6];
                                ^~~~~~~~~~~~~~~~~~~~~~~
C:\test.rs:4:18: 4:24 error: const index-expr is out of bounds
C:\test.rs:4    static v: int = VEC[6];
                                                ^~~~~~

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed!

Program: C:\Program Files (x86)\Rust\bin\rustc.exe
File: c:/bot/slave/nightly-win/build/src/llvm/lib/IR/Constants.cpp, Line 2021

Expression: ReqTy && "extractvalue indices invalid!"
[Finished in 1.0s with exit code 3]

Xubuntu 13.10
rustc 0.11-pre-nightly (a5cd502 2014-04-22 02:06:35 -0700)
host: x86_64-unknown-linux-gnu

test.rs:1:1: 1:39 warning: code is never used: `VEC`, #[warn(dead_code)] on by default
test.rs:1 static VEC: [int, ..4] = [0, 1, 2, 3];
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:4:2: 4:25 warning: code is never used: `v`, #[warn(dead_code)] on by default
test.rs:4   static v: int = VEC[6];
            ^~~~~~~~~~~~~~~~~~~~~~~
test.rs:4:18: 4:24 error: const index-expr is out of bounds
test.rs:4   static v: int = VEC[6];
                            ^~~~~~
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Constants.cpp:2021: static llvm::Constant* llvm::ConstantExpr::getExtractValue(llvm::Constant*, llvm::ArrayRef<unsigned int>): Assertion `ReqTy && "extractvalue indices invalid!"' failed.
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions