https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378

--- Comment #3 from Pedro Alves <alves.ped at gmail dot com> ---
BTW, I found it curious that empty2 and empty3 get their own addresses, even at
run time, when they could have all been squashed to the same address.  I.e.,
e.g., this ends up with sizeof == 3, when it could have been 1, I believe:

 struct Empty {};

 struct S
 {
   [[no_unique_address]] Empty empty1;
   [[no_unique_address]] Empty empty2;
   [[no_unique_address]] Empty empty3;
 };

Clang also gives empty2 and empty3 unique addresses and sizeof(S)==3.

ABI compatibility could prevent changing this, of course.

Clang also gets the DWARF right, BTW.  For the example above:

 <2><48>: Abbrev Number: 4 (DW_TAG_member)
    <49>   DW_AT_name        : (indirect string, offset: 0x55): empty1
...
    <53>   DW_AT_data_member_location: 0
 <2><54>: Abbrev Number: 4 (DW_TAG_member)
    <55>   DW_AT_name        : (indirect string, offset: 0x62): empty2
...
    <5f>   DW_AT_data_member_location: 1
 <2><60>: Abbrev Number: 4 (DW_TAG_member)
    <61>   DW_AT_name        : (indirect string, offset: 0x69): empty3
...
    <6b>   DW_AT_data_member_location: 2

Reply via email to