Skip to content

Don't allow array types in extern "C" functions. #16221

Closed
@mahkoh

Description

@mahkoh

You cannot pass an array to or return an array from a C function. f(char x[N]) is equivalent to f(char *x) for every N. On x86_64 linux, the following two extern "C" functions produce the same assembly:

extern "C" {
    fn f(x: [i32, ..4]); // void f(int x[4])
    fn g(x: i64, y: i64);
}

This will segfault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions