Skip to content

Mir: translation of indexing is incorrect #30474

Closed
@nagisa

Description

@nagisa
const C: [u32; 5] = [0, 42, 112, 212, 433];

#[rustc_mir(graphviz="foo.gv")]
fn mir() {
    C[3];
}

fn main(){}

will fail to compile with an LLVM abort:

Stored value type does not match pointer operand type!
  store [5 x i32] %4, i32* %temp1, align 4
 i32Invalid bitcast
i8 addrspace(9)* bitcast (%str_slice { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str3466, i32 0, i32 0), i64 7 } to i8 addrspace(9)*)

Seems to be a mis-translation of indexing (trans/mir/lvalue at ProjectionElem::Index).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions