Skip to content

Compiler error with float structs and foreign functions #6753

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

Closed
jeremyletang opened this issue May 26, 2013 · 2 comments
Closed

Compiler error with float structs and foreign functions #6753

jeremyletang opened this issue May 26, 2013 · 2 comments
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jeremyletang
Copy link
Contributor

I'm trying de do a binding for a c library and i get an error when i try to pass a struct of float to a C foreign function. This is the error given by rustc :

rust: task failed at 'index out of bounds: the len is 2 but the index is 2', /rust_install/rust-0.6/src/librustc/middle/trans/cabi_x86_64.rs:248
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /rust_install/rust-0.6/src/librustc/rustc.rc:357
rust: domain main @0x13863c0 root task failed

And this is the code who produce the error

#[link(name = "my_lib",
       vers = "0.1")];

#[crate_type = "lib"];

use core::libc::{c_void};

pub extern "C" {
    fn rect_create() -> *rect;
    fn set_point(rect : *rect, pos : Vector2f) -> ();
}

pub struct rect {
    This : *c_void
}

pub struct Vector2f {
    x : f32,
    y : f32
}

pub struct RectWrapped {
    priv rect : *rect
}

impl RectWrapped {
    pub fn new() -> RectWrapped {
        RectWrapped {rect :  unsafe {rect_create()}}
    }
}
@sanxiyn
Copy link
Member

sanxiyn commented May 27, 2013

Can you try this again with the latest version? I believe this has been fixed.

@jeremyletang
Copy link
Contributor Author

I've just tested with the latest version and the bug is solved. Thanks.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 1, 2021
…ip1995

check for unbalanced tick pairs in doc-markdown lint

fixes rust-lang#6753

changelog: check for unbalanced tick pairs in doc-markdown lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants