Pre-RFC: Define the behavior of `repr(transparent)` when all fields are zero-sized types

Okay so what I am hearing (above and elsewhere) is that in principle, we can always define the Rust version of extern "C" such that repr(transparent) works. We just need to ensure that zero-sized fields are skipped during layout adjustments. That cannot be incompatible with any standard C program since standard C programs cannot have such fields. Right?

The main risk then is running into a target where someone else has already extended the ABI to allow zero-sized fields, and they did that in a way that is incompatible with just skipping them. We currently don't know if that is the case for any of the targets -- except that we ourselves defined extensions e.g. to the sparc64 C ABI that are incompatible with our own goals, and there's a risk that changing that ABI could break existing code. OTOH sparc64 is an unmaintained tier 2 target so... maybe that risk is not very high.

What I am now very confused about, however, is this part of our ABI logic. That comment claims very definitely that certain platform C ABIs do not ignore zero-sized struct arguments. What is that based on, given that C has no such thing?

1 Like