On 4/27/20 3:53 PM, Jonathan Wakely wrote:
On 27/04/20 21:47 +0200, Jakub Jelinek wrote:
On Mon, Apr 27, 2020 at 03:32:29PM -0400, Jason Merrill wrote:
Note that C++20 adds empty non-static data members with the
[[no_unique_address]] attribute.  How will that fit into these ABIs and the
others that had issues with parameter passing?

Are they also represented in the trees handed over to the middle-end
as FIELD_DECLs with bitsize_zero DECL_SIZE and TREE_TYPE that contains
padding (like the empty base field does)?

Yes.

Or are they just like say C empty structs in other structs (bitsize_zero
DECL_SIZE and TYPE_SIZE of TREE_TYPE)?

I bet they aren't DECL_ARTIFICIAL, but should have the no_unique_address
attribute on them, so the backends or some helper function in calls.c
could again catch them and decide what to do.

Yes.

I guess at least we don't have an ABI incompatibility between different
-std=* versions,

We kind of do, because the intention of the attribute is to match the
behaviour of the empty base-class optimization.

I need it to be possible to replace this:

struct empty { };
struct X : empty { };

with this:

struct empty { };
struct X { [[no_unique_address]] empty e; };

and have them be layout compatible, otherwise the attribute is useless
to the standard library.

Why are zero-size fields changing layout/parameter passing in these ABIs, anyway?

Jason

Reply via email to