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

[Windows] Returning structures from functions has wrong ABI #15928

Closed
timurrrr opened this issue Mar 21, 2013 · 3 comments
Closed

[Windows] Returning structures from functions has wrong ABI #15928

timurrrr opened this issue Mar 21, 2013 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@timurrrr
Copy link
Contributor

Bugzilla Link 15556
Resolution FIXED
Resolved on Oct 13, 2020 15:57
Version trunk
OS Windows NT
Blocks #12849 #14048
CC @asl,@echristo,@rnk

Extended Description

Example:

$ cat cl.c
struct S {
int a, b, c;
};

struct S foo(void);

int main(void) {
struct S s = foo();
if (s.a != 1)
return 1;
if (s.b != 2)
return 2;
if (s.c != 3)
return 3;
return 0;
}

int printf(const char *fmt, ...);

void do_something_complex(void) {
printf("%d %d %d %d\n", 1, 2, 3, 4);
}

struct S {
int a, b, c;
};

struct S foo(void) {
struct S ret;
ret.a = 1;
ret.b = 2;
ret.c = 3;
do_something_complex();
return ret;
}

$ cl cl.c clang.c && ./cl.exe; echo $?
-> works fine

As of r177589,
$ clang clang.c -c && cl -c cl.c && link clang.o cl.obj && ./clang.exe ; echo $?
-> Segmentation Fault after the printf.

@timurrrr
Copy link
Contributor Author

assigned to @timurrrr

@timurrrr
Copy link
Contributor Author

Fixed by r178291.

@Myriachan
Copy link
Mannequin

Myriachan mannequin commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#47836

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 4, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

1 participant