Skip to content
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

fix Issue 9931 - Mac OS X ABI not followed when returning structs for extern (C) #1938

Merged
merged 1 commit into from
Apr 26, 2013

Conversation

WalterBright
Copy link
Member

@yebblies
Copy link
Member

Test case...?

@jacob-carlborg
Copy link
Contributor

Here's a test case. Of course it should be in the pull request. Just compile the C and D code and run the executable. It should not segfault.

C code:

struct Foo
{
    int a;
    int b;
    int c;
};

typedef struct Foo Foo;

Foo foo (int a)
{
    Foo f;
    f.a = 1;
    f.b = 2;
    f.c = 3;
    return f;
}

D code:

struct Foo
{
    int a;
    int b;
    int c;
}

extern (C) Foo foo (int a);

Foo bar ()
{
    return foo(0);
}

void main ()
{
    auto frame = bar();
}

@MartinNowak
Copy link
Member

Test case...?

Relies on a particular C compiler.
Of course we should add C-ABI tests, but as that would require to extend the test framework I'm going to merge this now.

MartinNowak added a commit that referenced this pull request Apr 26, 2013
fix Issue 9931 - Mac OS X ABI not followed when returning structs for extern (C)
@MartinNowak MartinNowak merged commit 5167cc1 into dlang:master Apr 26, 2013
@jacob-carlborg
Copy link
Contributor

Awesome, thanks.

@WalterBright WalterBright deleted the fix9931 branch April 26, 2013 18:04
MartinNowak added a commit that referenced this pull request Apr 26, 2013
fix Issue 9931 - Mac OS X ABI not followed when returning structs for extern (C)
@jacob-carlborg
Copy link
Contributor

Unfortunately there's still an issue with 64bit. It doesn't segfault but it doesn't given the correct result for the returned struct. See the original bug report: http://d.puremagic.com/issues/show_bug.cgi?id=9931#c26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants