Skip to content

Segfault on Mac when function cast to borrowed trait invokes self in its impl #4775

Closed
@pnkfelix

Description

@pnkfelix
% uname -a
Darwin fklockii-Eris.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

% rustc --version
rustc 0.6 (77ee858 2013-02-02 11:54:29 +0100)
host: x86_64-apple-darwin

% cat bug5.rs
fn echo<T>(x:T) { io::println(fmt!("%?", x)); }

pub trait OpInt { fn call(&self, int, int) -> int; }

impl fn(int,int) -> int : OpInt {
    fn call(&self, a:int, b:int) -> int {
        echo("I dont wanna die!");
        (*self)(a,b)
    }
}

fn squarei(x:int, op:&OpInt) -> int       { op.call(x, x) }

fn muli(x:int, y:int) -> int {
    echo("You will never get here.");
    x * y
}


fn main() {
    echo("Entered main");
    let r = squarei(3, (|x,y|muli(x,y)) as &OpInt); echo(r);
}

% rustc bug5.rs && ./bug5
warning: no debug symbols in executable (-arch x86_64)
"Entered main"
"I dont wanna die!"
Segmentation fault: 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions