<i>IIRC unions are a common example.</i><p>If you mean type punning: That is fine in C (chapter 6.5.2.3 of the C11 Standard even mentions &quot;type punning&quot; in footnote 95), but not in C++, where it&#x27;s undefined behavior.<p>I would just use memcpy. It works even when C code is compiled as C++, and modern compilers know what memcpy does and can optimize its call to a move operation: <a href="http:&#x2F;&#x2F;blog.regehr.org&#x2F;archives&#x2F;959" rel="nofollow">http:&#x2F;&#x2F;blog.regehr.org&#x2F;archives&#x2F;959</a>