Skip to content

LLVM abort when using pointer arithmetic in unsafe statics #17452

Closed
@mahkoh

Description

@mahkoh
static X: uint = unsafe { *(0 as *const uint) };
rustc: /build/rust-git/src/rust/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::GlobalVariable; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::GlobalVariable*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
struct X {
    i: int,
    j: u8,
}

static SIZE_OF_X: uint = unsafe { &(*(0 as *const [X, ..2]))[1] as *const X as uint };
same as above

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