Skip to content

segfault on i686-unknown-linux-gnu returning a struct from C #5347

Closed

Description

struct rust_dbg_struct {
    a: uint,
    b: uint
}

extern {
    fn rust_dbg_return_struct() -> rust_dbg_struct;
}

fn main() {
    unsafe {
        let s = rust_dbg_return_struct();
        fail_unless!(s.a == 10);
        fail_unless!(s.b == 20);
    }
}

The C code:

struct rust_dbg_struct {
    uintptr_t a;
    uintptr_t b;
};

extern "C" rust_dbg_struct
rust_dbg_return_struct() {
    struct rust_dbg_struct s;
    s.a = 10;
    s.b = 20;
    return s;
}

Related to #2064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-codegenArea: Code generation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions