Skip to content

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

Closed
@Kimundi

Description

@Kimundi
Member

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)

Activity

Twisol

Twisol commented on Jan 4, 2015

@Twisol

/cc @eddyb

steveklabnik

steveklabnik commented on Jan 16, 2015

@steveklabnik
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

emberian commented on Jan 20, 2015

@emberian
Member

Confirm.

added
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
A-codegenArea: Code generation
on Jan 20, 2015
JustAPerson

JustAPerson commented on Mar 29, 2015

@JustAPerson
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);
    }
}
self-assigned this
on Mar 30, 2015
tamird

tamird commented on Apr 21, 2015

@tamird
Contributor

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

jooert

jooert commented on May 11, 2015

@jooert
Contributor

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.
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[/+] on May 12, 2015
pmarcelll

pmarcelll commented on Jun 19, 2015

@pmarcelll
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
added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Jun 19, 2015
alexcrichton

alexcrichton commented on Jun 19, 2015

@alexcrichton
Member

Agreed!

emberian

emberian commented on Jun 19, 2015

@emberian
Member

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

alexcrichton

alexcrichton commented on Jun 19, 2015

@alexcrichton
Member

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

added 2 commits that reference this issue on Jul 20, 2018

Rollup merge of rust-lang#52527 - ljedrz:cleanup_13973, r=oli-obk

6cd5dbf

Rollup merge of rust-lang#52527 - ljedrz:cleanup_13973, r=oli-obk

e10194d
added a commit that references this issue on Feb 13, 2023

Auto merge of rust-lang#13973 - lnicola:replace-arith, r=lnicola

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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

      Participants

      @steveklabnik@Twisol@alexcrichton@pnkfelix@emberian

      Issue actions

        LLVM assert abort while trying to take address of raw pointer in static · Issue #13973 · rust-lang/rust