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

Assertion error in 'process_aggregate_arg' for anonymous struct/union #392

Closed
andy-hanson opened this issue Mar 16, 2024 · 2 comments
Closed

Comments

@andy-hanson
Copy link

andy-hanson commented Mar 16, 2024

#include <stdio.h>
struct S {
	int filler;
	struct {
		const char* str;
	};
};
void f(struct S a) {
	printf("%s\n", a.str);
}
void main(void) {
	f((struct S) {.str = "foo"});
}

Running c2m a.c -eg: This should print "foo". Instead there is an internal assertion error:

c2m: c2mir/x86_64/cx86_64-ABI-code.c:314: process_aggregate_arg: Assertion `FALSE' failed.

Tested using a local build of commit 9b7aa03 with make debug then sudo make install.

The error seems to happen if there is any anonymous struct or union that contains a pointer member. There's no error if I break it out to a named type, remove int filler;, or use char str[4] instead.

@vnmakarov
Copy link
Owner

Thank you for reporting this. It revealed wrong passing such structures as arguments for x86-64 and riscv64 call ABI.

I fixed it by 62c4ece and 5ce509e.

@andy-hanson
Copy link
Author

Thanks, I confirmed it's working now.

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

No branches or pull requests

2 participants