Skip to content

LLVM abort from deref of 0 in a const expression initializing a static #24581

Closed
@pnkfelix

Description

@pnkfelix

(imported from improperly closed bug #17452)

static X: usize = unsafe { *(0 as *const usize) };

fn main() {
    println!("X: {}", X);
}

playpen

This causes LLVM to abort, causing a core dump from rustc. :(

(I suspect we should be more careful, somehow, about handling such things in our const expression evaluator. Not 100% sure how best to resolve this though.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions