Skip to content

Unusual return value from FnOnce closure #16591

Closed
@tomjakubowski

Description

@tomjakubowski
#![feature(unboxed_closures, unboxed_closure_sugar)]

use std::ops::FnOnce;

fn main() {
    let task: Box<|: int| -> int> = box |: x| x;
    let (vtable, data): (*mut (), *mut ()) = unsafe { std::mem::transmute_copy(&task) };
    println!("vtable {}", vtable);
    println!("data   {}", data);
    println!("return 0x{:x}", task.call_once((0i, )));
}

prints something like:

vtable 0x7f9fa1b750c0
data   0x7f9fa1b7bc40
return 0x7f9fa1b7bc40

task.call_once() with a string slice tends to cause a segfault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions