Skip to content

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

@lifthrasiir

Description

@lifthrasiir
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.

Activity

emberian

emberian commented on Oct 4, 2013

@emberian
Member

Reproduced on Linux.

klutzy

klutzy commented on Oct 4, 2013

@klutzy
Contributor

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

klutzy commented on Oct 5, 2013

@klutzy
Contributor

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

klutzy commented on Oct 5, 2013

@klutzy
Contributor

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

cnd commented on Nov 7, 2013

@cnd
Contributor

cc

alexcrichton

alexcrichton commented on Mar 2, 2014

@alexcrichton
Member

This has been fixed, flagging as needstest.

added a commit that references this issue on Mar 6, 2014
13e10f5
added a commit that references this issue on Mar 6, 2014
0e95b08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @alexcrichton@lifthrasiir@emberian@klutzy@cnd

      Issue actions

        An option of a generic pointer triggers an LLVM assertion · Issue #9719 · rust-lang/rust