Skip to content

ICE: Assertion failed: DestTy && "GEP indices invalid!" compiling reference to static defined in another crate #29265

@briansmith

Description

@briansmith

Program:

extern crate test_1_lib;

static _UNUSED: &'static test_1_lib::SomeType = &test_1_lib::SOME_VALUE;

fn main() {
    vec![0u8; test_1_lib::SOME_VALUE.some_member];
}

Crate test_1_lib:

pub struct SomeType {
    pub some_member: usize,
}

pub static SOME_VALUE: SomeType = SomeType {
    some_member: 1,
};

Notice that this is a static in one crate referencing a static in another crate.

A complete cargo-buildable test case is at https://github.com/briansmith/rust-bug-1. This bug was found by a user of ring. The coding pattern in this test case commonly occurs when using ring.

To reproduce:

git clone https://github.com/briansmith/rust-bug-1
cd bin
cargo build

rustc crashes with

Assertion failed: DestTy && "GEP indices invalid!", file C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\llvm\

Reproduced with (on x86_64-pc-windows-msvc):

  • rustc 1.3.0 (9a92aaf 2015-09-15) / cargo 0.4.0-nightly (553b363 2015-08-03) (built 2015-08-03)
  • rustc 1.4.0-nightly (fd302a9 2015-08-27) / cargo 0.5.0-nightly (53e51d5 2015-08-26)
  • rustc 1.5.0-nightly (7beebbe 2015-10-22) / cargo 0.6.0-nightly (e1ed995 2015-10-22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions