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 assertion failure with with borrowed pointer in struct #5884

Closed
alexcrichton opened this issue Apr 15, 2013 · 2 comments
Closed

LLVM assertion failure with with borrowed pointer in struct #5884

alexcrichton opened this issue Apr 15, 2013 · 2 comments
Assignees
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@alexcrichton
Copy link
Member

This program

pub struct Foo {
  a: int,
}

struct Bar<'self> {
  a: ~Option<int>,
  b: &'self Foo,
}

fn check(a: @Foo) {
  let mut _ic = Bar{ b: a, a: ~None };
}

fn main(){}

yields

$ rustc foo.rs
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /Users/alex/code/rust-src/src/llvm/lib/IR/Instructions.cpp, line 281.

This cropped up after the new self lifetimes as I tried to change field b from @Foo to &'self Foo. If the owned pointer from Bar is removed (even just the sigil), the assertion still trips.

One solution I found is:

fn check(b: @Foo) {
  let a = ~None;
  let mut _ic = Bar{ b: b, a: a };
}
@ghost ghost assigned nikomatsakis Apr 15, 2013
@Aatch
Copy link
Contributor

Aatch commented Jun 7, 2013

Oh what a suprise, it's because of glue_* glue emission needs some serious work.

@emberian
Copy link
Member

emberian commented Aug 5, 2013

Works now; needs addition to test suite

bors added a commit that referenced this issue Aug 15, 2013
Closes #3907
Closes #5493
Closes #4464
Closes #4759
Closes #5666
Closes #5884
Closes #5926
Closes #6318
Closes #6557
Closes #6898
Closes #6919
Closes #7222
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
Add the other overloadable operations to suspicious_arithmetic_impl

In rust-lang#2268 I idly mused that the other user-overloadable operations could be added to this lint. Knowing that the lint was arguably incomplete was gnawing at the back of my mind, so I figured that I might as well make this PR, particularly given the change needed was so small.

changelog: Start warning on suspicious implementations of the `BitAnd`, `BitOr`, `BitXor`, `Rem`, `Shl`, and `Shr` traits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants