[Bug debug/101378] Negative DW_AT_data_member_location

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 9 13:24:50 GMT 2021


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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The C++ standard forbids two objects of the same type having the same address.
That is true for the empty base-class optimization and it's true for
[[no_unique_address]].

[intro.object]

> Two objects with overlapping lifetimes that are not bit-fields may have the
> same address if one is nested within the other, or if at least one is a
> subobject of zero size and they are of different types; otherwise, they have
> distinct addresses and occupy disjoint bytes of storage.

There is a footnote that says:

> Under the “as-if” rule an implementation is allowed to store two objects at
> the same machine address or not store an object at all if the program cannot
> observe the difference.

But I don't think GCC does that, because if some property that is reflected in
the debuginfo would allow you to observe the difference, then it's not allowed.


More information about the Gcc-bugs mailing list