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

--- Comment #63 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #54)
> > > > --- Comment #51 from Bernd Edlinger <bernd.edlinger at hotmail dot de> 
> > > > ---
> > > > Doesn't 3.10/10 explicitly say that it is undefined to use a union to
> > > > to move an object representation that is not a member of the union?

> But still the other clause says the storage representation is transfered
> and so you could read into that that no "access" happens and thus
> 3.10/10 doesn't apply.

Right, union copy copies the bytes of the object representation, i.e. memcpy.

(In reply to Richard Biener from comment #50)
> Note that what changed with GCC 7 is only that unions with char members
> no longer behave as alias-set zero but 12.8/16 talks about all unions,
> not just unions with char members.
> 
> Now I read comment#14 as that _only_ char[] members (of structs or unions)
> may ever "contain" different dynamic types.  Any pointer to a part of
> the standard that singles out char[] that way?

char is special that way because it can be used to access the stored value of
an object of any type (3.10/10.8).

Now that C++17 introduces std::byte for this sort of thing, I hope to
transition away from the permissive aliasing behavior of char.

Reply via email to