Skip to content

An option of a generic pointer triggers an LLVM assertion #9719

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lifthrasiir opened this issue Oct 4, 2013 · 6 comments · Fixed by #12738
Closed

An option of a generic pointer triggers an LLVM assertion #9719

lifthrasiir opened this issue Oct 4, 2013 · 6 comments · Fixed by #12738
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@lifthrasiir
Copy link
Contributor

Minimal example:

pub trait X { fn f(&self); }
impl X for int { fn f(&self) {} }
pub struct Z<'self>(Option<&'self X>);
pub fn main() { let x = 42; let z = Z(Some(&x as &X)); let _ = z; }

In my Windows machine, it results in:

Assertion failed: (i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!", file c:/bot/slave/dist2-win/build/src/llvm/lib/IR/Instructions.cpp, line 281

Reproduced on Rust 0.8 and 0.9-pre (371a7ec). It doesn't seem to be Windows specific either.

@emberian
Copy link
Member

emberian commented Oct 4, 2013

Reproduced on Linux.

@klutzy
Copy link
Contributor

klutzy commented Oct 4, 2013

Example without Option:

pub enum Enum<T> {
    A(T),
}

pub trait X {}
impl X for int {}

pub struct Z<'self>(Enum<&'self X>);
pub fn main() { let x = 42; let z = Z(A(&x as &X)); let _ = z; }

@klutzy
Copy link
Contributor

klutzy commented Oct 5, 2013

It occurs only with tuple structs; as a workaround, you may replace

struct Z<'self>(Enum<&'self X>);

with

struct Z<'self>{
    z: Enum<&'self X>
}

@klutzy
Copy link
Contributor

klutzy commented Oct 5, 2013

Sorry. It doesn't solve it generally. I'm now embarrassed that

trait X {}
impl X for int {}
struct Y<'self>{
    x:Option<&'self X>,
}

fn main() {
    let x = 42;
    let a = Some(&x as &X);
    let _y = Y { x: a };
}

works, but

...
fn main() {
    let x = 42;
    let _y = Y { x: Some(&x as &X) }; // inlining a
}

does not.

@cnd
Copy link
Contributor

cnd commented Nov 7, 2013

cc

@alexcrichton
Copy link
Member

This has been fixed, flagging as needstest.

bors added a commit that referenced this issue Mar 6, 2014
Closes #6738
Closes #7061
Closes #7899
Closes #9719
Closes #10028
Closes #10228
Closes #10401
Closes #11192
Closes #11508
Closes #11529
Closes #11873
Closes #11925
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.

5 participants