-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
ICE #15469
Comments
Could you post a reproducing example? (Even if it's not minimal, although that would be nice. :) ) Just substituting best-guess definitions in naively doesn't reproduce the ICE: extern crate libc;
use libc::{c_void, c_int};
struct LivelyPenData { pen: uint, cb: extern "C" fn() }
struct LivelyPenEvent { id: c_int, data: Box<LivelyPenData> }
extern "C" fn pen_lively_callback() {}
extern "C" fn cb() {}
mod c {
extern {
pub fn tickit_pen_bind_event(x: uint, ev: (), fun: Option<extern "C" fn()>, ptr: *mut ::libc::c_void) -> ::libc::c_int;
}
}
fn main() {
let ev = ();
unsafe
{
let fun = Some(pen_lively_callback);
let data = box LivelyPenData{pen: 0, cb: cb};
let mut id: c_int = 0;
{
let raw_data_ptr: *const *const LivelyPenData = std::mem::transmute(&data);
let raw_data = *raw_data_ptr;
let raw_data: *mut c_void = std::mem::transmute(raw_data);
id = c::tickit_pen_bind_event(0, ev, fun, raw_data);
};
LivelyPenEvent{id: id, data: data}
};
} That compiles (on the playpen) with a pile of warnings and a linkage error, but no ICE. |
Looks like the external C functions needing the data pointer was a red herring. #![crate_type = "dylib"]
struct Boxee<'a> {
cb: ||: 'a,
}
pub struct Boxer<'a> {
data: Box<Boxee<'a>>,
}
impl<'a> Drop for Boxer<'a> {
fn drop(&mut self) {
println!("dropping boxer");
}
}
pub fn build_it<'a>(cb: ||: 'a) -> Boxer<'a> {
let data = box Boxee{cb: cb};
Boxer{data: data}
} The ICE appeared once I added the Drop impl, but the fact that I'm taking a lifetime'd closure is also relevant. If I change the closure to 'static, I get an error (regardless of whether I leave the unused 'a lifetime on everything else):
If I replace the closure with an If I impl Drop for Boxee instead of Boxer, there is no change. |
If I follow the error's suggestion and use |
Dupe of #14889. |
What I'm trying to do is turn a Box into a *mut c_void. I've hit this with several variants of the following code:
The text was updated successfully, but these errors were encountered: