Skip to content

LLVM assertion failure when returning a value of a user defined type through a transmuted nested Box holding a trait object #20994

Closed
@crumblingstatue

Description

@crumblingstatue

Test case:

struct Foo {
    memb: i32
}

trait FooHolder {
    fn foo(&self) -> Foo;
}

// ↓ The `extern` marker is necessary to trigger the assertion failure
extern fn get_foo(ptr: *const ()) -> Foo {
    let wrap: Box<Box<FooHolder + Send>> = unsafe { ::std::mem::transmute(ptr) };
    wrap.foo()
}

fn main() {}

This triggers the following assertion failure:

rustc: /build/rust-git/src/rust/src/llvm/lib/IR/Instructions.cpp:1086: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.

The assertion failure does not occur with (099b411e0 2015-01-10 16:20:04 +0000)�, but it does with (e7b397b02 2015-01-11 22:15:52 +0000).

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