Skip to content

LLVM Assertion Failure “Ptr must be a pointer to Val type!” #22346

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

Closed
yggie opened this issue Feb 14, 2015 · 0 comments · Fixed by #22366
Closed

LLVM Assertion Failure “Ptr must be a pointer to Val type!” #22346

yggie opened this issue Feb 14, 2015 · 0 comments · Fixed by #22366
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@yggie
Copy link

yggie commented Feb 14, 2015

I ran into a very strange issue today, the code that can replicate the issue is as follows:

struct Foo;

impl Foo {
    fn iter(&self) -> Box<Iterator<Item=usize>> {
      return Box::new(range(0, 3).map(|i| { return i; }));
    }
}

fn main() {
  for i in Foo.iter() {
    println!("{:?}", i);
  }
}

This generates the following error on the Rust playpen:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:1083: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
Aborted (core dumped)
playpen: application terminated with error code 134

A minor change to the closure fixes the issue:

// ...
      return Box::new(range(0, 3).map(|i| i )); // without the explicit return inside the closure
// ...

This variant also works:

// ...
      Box::new(range(0, 3).map(|i| { return i; })) // without the explicit return outside the closure
// ...

If it helps, this is the output from rustc --version --verbose

rustc 1.0.0-nightly (b9ba643b7 2015-02-13 21:15:39 +0000)
binary: rustc
commit-hash: b9ba643b72ea6104bcb1209d238f6b445e3b51fc
commit-date: 2015-02-13 21:15:39 +0000
host: x86_64-apple-darwin
release: 1.0.0-nightly
dotdash added a commit to dotdash/rust that referenced this issue Feb 15, 2015
Without the adjustments the retslot might have the wrong type, e.g. when
the return value is implicitly coerced to a trait object.

Fixes rust-lang#22346
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 15, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 17, 2015
Without the adjustments the retslot might have the wrong type, e.g. when
the return value is implicitly coerced to a trait object.

Fixes rust-lang#22346
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants