Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] consider more offsets when laying out empty subobjects #77

Open
zygoloid opened this issue Apr 10, 2019 · 1 comment
Open

[v2] consider more offsets when laying out empty subobjects #77

zygoloid opened this issue Apr 10, 2019 · 1 comment

Comments

@zygoloid
Copy link
Contributor

Currently, when laying out an empty subobject, we only consider offset zero, followed by offsets >= dsize of the class. We never consider the multiples of [nv]alignof the subobject that are greater than zero and less than the dsize of the class.

Considering those additional offsets would reduce the size of some classes. For example:

struct noncopyable {};
struct A : noncopyable {};
struct B { int n; };
struct C : noncopyable {};
struct D1 : A, B, C {}; // sizeof(D1) == 8, could be 4
struct D2 { // sizeof(D2) == 8, could be 4
  [[no_unique_address]] A a;
  B b;
  [[no_unique_address]] C c;
};
@zygoloid zygoloid changed the title consider more offsets when laying out empty subobjects [v2] consider more offsets when laying out empty subobjects Apr 10, 2019
@daveedvdv
Copy link

daveedvdv commented Apr 10, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants