Skip to content

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

Closed

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)

Activity

  1. changed the title [-]Compiler crash. Assigning static item using out of bounds index.[/-] [+]Assertion failed. Assigning static item using out of bounds index.[/+] on Apr 23, 2014
  2. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Sep 22, 2014
  3. ghost added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Nov 7, 2014
  4. ghost removed
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Dec 12, 2014
  5. Twisol commented on Jan 4, 2015

    @Twisol
    Contributor

    /cc @eddyb

  6. steveklabnik commented on Jan 16, 2015

    @steveklabnik
    Contributor

    triage:

    hello.rs:4:25: 4:31 error: const index-expr is out of bounds
    hello.rs:4         static v: int = VEC[6];
                                       ^~~~~~
    rustc: /home/steve/src/rust/src/llvm/lib/IR/Constants.cpp:2176: static llvm::Constant* llvm::ConstantExpr::getExtractValue(llvm::Constant*, llvm::ArrayRef<unsigned int>, llvm::Type*): Assertion `ReqTy && "extractvalue indices invalid!"' failed.
    
  7. JustAPerson commented on Mar 29, 2015

    @JustAPerson
    Contributor

    tl;dr: this bug appears to be fixed.
    Updated for current Rust (on playpen as of today 29 March 2015):

    @pix64's example does not crash but still gives an out of bound error:

    const VEC: [isize; 4] = [0, 1, 2, 3];
    
    fn main() {
        static v: isize = VEC[6];
    }
  8. alexcrichton commented on Mar 30, 2015

    @alexcrichton
    Member

    Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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