Skip to content

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

Description

@brson
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

Activity

  1. brson commented on Mar 12, 2013

    @brson
    ContributorAuthor

    Blocks #4419

  2. nikomatsakis commented on Mar 12, 2013

    @nikomatsakis
    Contributor

    Also see src/test/run-pass/extern-pass-TwoU64s{,-ref}.rs which are currently xfail-test'd in relation to this issue

  3. nikomatsakis commented on Mar 12, 2013

    @nikomatsakis
    Contributor

    The symptom is different but I suspect the underlying fault is the same.

  4. graydon commented on May 1, 2013

    @graydon
    Contributor

    assigning bug; change assignment if you disagree

  5. ghost assigned on May 1, 2013
  6. brson commented on May 2, 2013

    @brson
    ContributorAuthor

    This is fixed, but #5745 is a followup.

  7. added a commit that references this issue on May 2, 2020
    1ff81c1
  8. added a commit that references this issue on Aug 21, 2026
  9. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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