In C and C++, most zero-sized types are a compiler extension.
Specifically for arrays, the ABIs for arrays and pointers passed directly as arguments are equivalent (arrays decay to pointers). However, arrays of different lengths are incompatible, and passing incompatible lengths causes undefined behaviour.
This can be overcome using type ident[static N] in the argument list. (static N means "an array of at least of length N".)
If C and C++ included zero-sized types in their standards, Rust could implement standards-conforming behaviour.
For more details see:
https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Non-transitive.20ABI.20compatibility.20in.20C/near/591424586
In C and C++, most zero-sized types are a compiler extension.
Specifically for arrays, the ABIs for arrays and pointers passed directly as arguments are equivalent (arrays decay to pointers). However, arrays of different lengths are incompatible, and passing incompatible lengths causes undefined behaviour.
This can be overcome using
type ident[static N]in the argument list. (static Nmeans "an array of at least of length N".)If C and C++ included zero-sized types in their standards, Rust could implement standards-conforming behaviour.
For more details see:
https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Non-transitive.20ABI.20compatibility.20in.20C/near/591424586