rust icon indicating copy to clipboard operation
rust copied to clipboard

LLVM assertion "Ptr must be a pointer to Val type!" failed.

Open ILyoan opened this issue 13 years ago • 8 comments

Compiling this code yield LLVM assertion "Ptr must be a pointer to Val type!"

pub mod Bar {
    pub struct Foo {
        v: int,
    }

    extern {
        #[rust_stack]
        pub fn foo(v: *Foo) -> Foo;
    }
}

fn main() { }

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

ILyoan avatar May 14 '13 09:05 ILyoan

#4653, #4760 and #6390 produce the same error message, but I'm not sure if those are the same issue.

ILyoan avatar May 14 '13 10:05 ILyoan

Reproduced 93c270c63d158805a068b8e7ced660df1051c3ca -- nominating for milestone 5, production-ready

catamorphism avatar Jul 18 '13 00:07 catamorphism

Note that #4653, #4760, and #6390 are all fixed, so this is a different bug (this is a common error message with many different causes).

catamorphism avatar Jul 18 '13 00:07 catamorphism

Reproduced. Slight minimization: if you switch the return value to a *Foo it gets through translation. So I think it's just the unhandled combination of #[rust_stack], extern and return-by-structure.

graydon avatar Jul 18 '13 06:07 graydon

0266172eae470050d9ca4f9de2df61377a770ec3 added a test (run-pass/issue-6470.rs)

catamorphism avatar Aug 19 '13 20:08 catamorphism

accepted for production-ready

catamorphism avatar Aug 29 '13 17:08 catamorphism

I am a bit surprised this doesn't work; it will probably depend on the specific ABI we test

nikomatsakis avatar Aug 29 '13 17:08 nikomatsakis

This code now compiles, looks like the test just needs to be un-xfail'd. Flagging as needstest

alexcrichton avatar Oct 11 '13 01:10 alexcrichton