RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

Matthijs van Duin via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 04:40:11 PST 2016


On 11 February 2016 at 11:53, H.J. Lu <hjl.tools at gmail.com> wrote:
> Since this isn't Plain Old Data (POD) for the purposes of layout, it
> isn't covered by my proposal for psABI.  I leave this to C++ ABI.

You never define "POD for the purposes of layout", and I can only
interpret it as being equivalent to "standard-layout". The property of
being trivially copyable/destructible is not a statement about layout
and my EmptyInt example is POD in every other aspect.

There's a good argument for trivially copyable/destructible being the
relevant property: it means an object can be copied simply by copying
its bytes and destroyed simply by discarding its storage. If the
object occupies no storage (other than padding) then these operations
become nops hence there is never a need to have a pointer/reference to
the original object.

The precise layout is not really important here, e.g. struct U is
unusually large considering its lack of data members, due to the need
for padding between its base classes, but this doesn't change the fact
it can be copied using no operation (and g++ indeed does).

Matthijs van Duin


More information about the cfe-commits mailing list