Skip to content

ABI for function call with big argument different than GCC (LLVM-54) #14

@rodrigorc

Description

@rodrigorc

I've noticed this while calling wifi_prov_mgr_init() that for some reason takes is argument by value, and its argument sizeof(wifi_prov_mgr_config_t) == 44.

But it can be seen with this simple code:

struct data {
    int x[6];
};
void foo(struct data a) {
    for (int i = 0; i < sizeof(a) / sizeof(a.x[0]); ++i)
        printf("%2d: %d\n", i, a.x[i]);
}

If I compile this code with CLang and call it from CLang, all is well. But if I compile it with GCC and call it from CLang, it prints garbage values.

If I reduce the x[6] to x[4] it works as expected.

But if I change the int x[4] to char x[4] it breaks in a different way, as if there were padding bytes between the elements of the array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions