Closed DaMilyutin closed 1 year ago
It's an ABI break
The bahavior of [[no_unique_address]]
is part of the Itanium ABI. It could be improved (see https://github.com/itanium-cxx-abi/cxx-abi/issues/77 for an example) however such improvements are ABI breaking.
So the best possible wording is already in place https://eel.is/c++draft/dcl.attr.nouniqueaddr , no way to improve it further without breaking things.
Idea We have EBO for empty base optimization. That reduces memory of object. In same way we have [[no_unique_address]] which does similar thing. However, this is not standadrized as behavior. (Or prove me wrong.)
What I'd like to see is default behavior is both for EBO/EMO.
I think we go wrong way using attributee for EMO where it should be default behavior. From other hand, we can add attribute [[unique_address]] for contrary behavior.
Examples `struct Empty { // methods, typedefs, static stuff... };
struct EmptyBase { // methods, typedefs, static stuff... }
struct Derived: EmptyBase // EBO kicks in by default { Data data; Empty empty; // EMO kicks in by default };
struct Derived: [[unique_address]] EmptyBase // attribute stops EBO { Data data; [[unique_address]] Empty empty; // attribute stops EMO };`