Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

LLVM assert abort while trying to take address of raw pointer in static #13973

Closed
Kimundi opened this issue May 6, 2014 · 10 comments
Closed
Assignees
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Kimundi
Copy link
Member

Kimundi commented May 6, 2014

Testcase:

fn main() {
    unsafe {
        static BLOCK_UNSAFE_SAFE_PTR: &'static int = &*(0xdeadbeef as *int);
    }
}

Output:

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.
fish: Job 1, “rustc bug_generic_static_function_ptr.rs ” terminated by signal SIGABRT (Abort)
@Twisol
Copy link

Twisol commented Jan 4, 2015

/cc @eddyb

@steveklabnik
Copy link
Member

Triage:

rustc: /home/steve/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.

@emberian
Copy link
Member

Confirm.

@emberian emberian added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-codegen Area: Code generation labels Jan 20, 2015
@JustAPerson
Copy link
Contributor

tl;dr: this bug still reproduces
Updated for current Rust (on playpen as of today, 29 March 2015):

This still fails the llvm assertion that @steveklabnik mentioned.

fn main() {
    unsafe {
        static BLOCK_UNSAFE_SAFE_PTR: &'static isize = &*(0xdeadbeef as *const isize);
    }
}

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

I am no longer able to reproduce this on rustc 1.0.0-dev (f46c4e158 2015-04-20) (built 2015-04-20)

@jooert
Copy link
Contributor

jooert commented May 11, 2015

This still fails (when LLVM assertions are enabled) with

rustc: /path/to/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.

@pnkfelix pnkfelix changed the title LLVM abort while trying to take address of raw pointer in static LLVM assert abort while trying to take address of raw pointer in static May 12, 2015
@pmarcelll
Copy link
Contributor

This fails with a regular build error on the latest nightly:

test.rs:3:57: 3:86 error: raw pointers cannot be dereferenced in statics [E0396]
test.rs:3         static BLOCK_UNSAFE_SAFE_PTR: &'static isize = &*(0xdeadbeef as *const isize);
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

@emberian emberian added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 19, 2015
@alexcrichton
Copy link
Member

Agreed!

@emberian
Copy link
Member

@alexcrichton is there a test for this? I didn't notice one.

@alexcrichton
Copy link
Member

Probably not specifically, but PRs which often fix issues like this tend to have their own test cases anyway.

pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
kennytm added a commit to kennytm/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
minor: Fix `replace_arith` assist label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

10 participants