Closed
Description
(imported from improperly closed bug #16221)
You cannot pass an array to or return an array from a C function.
The signature f(char x[N])
is equivalent to f(char *x)
for every N
in C. Therefore it is meaningless to write this in Rust, (or rather, it does not mean what a C programmer and/or FFI generation tool likely thinks it means):
extern "C" fn f(x: [i32, ..4]); // void f(int x[4])
Option for dealing with this:
- We can extend our existing lint to detect cases like this and warn about them.
- We could make the
extern "C" fn
form reject this signature, since the expected correspondence between Rust and C does not hold here. - If the Rust FFI binding generation scripts/programs out there are generating this sort of code, they need to be fixed.
Metadata
Metadata
Assignees
Labels
Area: Foreign function interface (FFI)Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.