Okay so for Power we have wording like
A struct, union, or long double, any of which shall be treated as a pointer to the object, or to a copy of the object where necessary to enforce call-by-value semantics.
And that is interpreted as applying even to zero-sized structs.
I looked at the ABI adjustments for power and they seem fine, and indeed by repr(transparent)
test passes on powerpc-unknown-linux-gnu. It also passes on s390x-unknown-linux-gnu and x86_64-pc-windows-gnu. loongarch64-unknown-linux-gnu and riscv64gc-unknown-linux-gnu have some code that matches on FieldsShape
but it passes my test, it seems to treat array and struct fields the same.
mips64-unknown-linux-gnuabi64 has a problem similar to sparc64.
Interestingly, the netbsd/openbsd sparc64 targets do treat all 1-ZST consistently; the magic exception only specifically applies to sparc64 on Linux. However, repr(transparent)
is still broken on them for non-zero-sized arrays.
Yeah, and since C also doesn't have by-value arrays, there's really no way that the ABI of [u8; N]
or TransparentWrapper<[u8; N]>
is prescribed by anything on the C side. The fact that those behave differently is entirely on us, and we'll have to see if we can do an ABI-breaking change on the Rust side to fix that.