1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00

[ELF] Do not allocate a byte for an empty class

In C++, the size of an empty class is 1 rather than 0 because every
object is guaranteed to have a unique address. But if we do not need
the unique address guarantee, we can add `[[no_unique_address]]` to
a class member to save 1 byte. This is a new C++20 feature.
This commit is contained in:
Rui Ueyama 2022-03-06 12:20:30 +09:00
parent a4fd7e3819
commit 9e11b40a99

View File

@ -1789,7 +1789,7 @@ public:
u8 referenced_by_regular_obj : 1 = false;
// Target-dependent extra members.
SymbolExtras<E> extra;
[[no_unique_address]] SymbolExtras<E> extra;
};
// If we haven't seen the same `key` before, create a new instance