ABI of a ZST in function argument position?

Is it guaranteed that a ZST argument has no effect on a function's ABI? For example, are the following two functions guaranteed to have the same ABI?

extern "C" {
    fn foo(a: u8, b: u16);
    fn bar(a: u8, x: (), b: u16);
}

I don't think so:

4 Likes

ZSTs in function argument position are definitely not just ignored, at least one ABI passes them as pointers. I reported a bug about rustc mishandling that a while ago and it got fixed here: fix handling of ZST in win64 ABI on windows-msvc targets by RalfJung · Pull Request #135204 · rust-lang/rust · GitHub

3 Likes