Rust GCC backend: Why and how
30 points by dryya
30 points by dryya
Let's show an example with this Rust function:
fn t(a: &i32) -> i32 { *a }The C equivalent looks like this:
int t(int *a) { if (!a) { return -1; } return *a; }
...why? surely the equivalent C code would be
int t(int *a) {
return *a;
}
The way to write a non-NULL pointer argument in C is
int t(int a[static 1]) {
return *a;
}
It’s a pity this feature has such obnoxious and obscure syntax that it’s basically never used. And non-NULL pointers can only be specified as function arguments, so you can’t typedef a nicer spelling. Half-arsed.