Skip to content

LLVM abort when using pointer arithmetic in unsafe statics #17452

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mahkoh opened this issue Sep 22, 2014 · 2 comments
Closed

LLVM abort when using pointer arithmetic in unsafe statics #17452

mahkoh opened this issue Sep 22, 2014 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mahkoh
Copy link
Contributor

mahkoh commented Sep 22, 2014

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
@mahkoh mahkoh changed the title LLVM coredump when using pointer arithmetic in unsafe statics LLVM abort when using pointer arithmetic in unsafe statics Sep 22, 2014
@mahkoh
Copy link
Contributor Author

mahkoh commented Sep 22, 2014

Looks like #17233. Either way, the what is the null pointer dereference up there supposed to do?

@ben0x539
Copy link
Contributor

Same error, probably comes down to the pointer deref.

extern crate libc;
fn main() {
    unsafe {
        static FOO: *const i8 = *(&"foo\0" as *const &str as *const *const i8);
        libc::puts(FOO);
    }
}

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 27, 2015
@mahkoh mahkoh closed this as completed Apr 11, 2015
@rust-lang rust-lang locked and limited conversation to collaborators Apr 11, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
fix(completion): complete async keyword

Fixes rust-lang#17452

Not entirely confident of the fix here, but my logic is that `async` should in general be offered in similar semantic scenarios as other keywords like `static` or `pub`.
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants