https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79671
--- Comment #35 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Richard Biener from comment #34) > C++14 12.8/16 says > > "The implicitly-defined copy/move constructor for a union X copies the > object representation (3.9) of X." > > 3.9/4 says > > "The object representation of an object of type T is the sequence of N > unsigned char objects... For trivially copyable types, the value > representation is a set of bits in the object representation that determines > a value,..." > > this suggests that the copying should work but the C++ FE may not simply > elide the copy construction by emitting > > c = *p; > > because that does _not_ implement memcpy semantics for the union member. > > Note the above may not apply at all here if B is POD and thus the assignment > is an assignment of PODs (I don't know all of the standard). It would still conflict with the wording of 3.10/10 (that is, if 3.10/10 is fulfilled the middle-end handles the copying above correct).