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

Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkaminsk at gcc dot gnu.org

--- Comment #4 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
The standard wording seem to explicitly allow this two Empty object to have
same address. Firstly [variant.variant.general] p1
(https://eel.is/c++draft/variant#variant.general-1) explicitly states that
object alternatives are nested within the variant object:
> When an instance of variant holds a value of alternative type T, it means 
> that a value of type T, referred to as the variant object's contained value, 
> is nested within ([intro.object]) the variant object.

And the core language gives carve-out in [intro.object] p10
(https://eel.is/c++draft/intro.object#10) for nested-within objects to have
same address:
> Two objects with overlapping lifetimes that are not bit-fields may have the 
> same address if:
>  (10.1)  one is nested within the other

So &std::get<Empty>(v.e) may have same address as v.e, and that may have same
address as v.

Reply via email to