Skip to content

ICE on using result of index operation on a constant to index into a constant #29914

Closed
@oli-obk

Description

@oli-obk
const ARR: [usize; 5] = [5, 4, 3, 2, 1];

fn main() {
    println!("{}", ARR[ARR[3]]);
}

causes

<anon>:5:24: 5:30 error: internal compiler error: index is not an integer-constant expression
<anon>:5     println!("{}", ARR[ARR[3]]);
                                ^~~~~~

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