<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 10, 2013, at 12:45 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">> + union {<br>> + uint8_t ArrayMember[sizeof(word_t)];<br>> + support::detail::packed_endian_specific_integral<br>> + <word_t, support::little, support::unaligned> EndianMember;<br>> + } buf = { { 0 } };<br>><br>> - typedef support::detail::packed_endian_specific_integral<br>> - <word_t, support::little, support::unaligned> Endian_T;<br>> - CurWord = *(Endian_T*)buf;<br>> + BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf),<br>> + buf.ArrayMember, NULL);<br>> + // Handle big-endian byte-swapping if necessary.<br>> + CurWord = buf.EndianMember;</p><p dir="ltr" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">This is still invalid C++ isn't it (UB to read from the non active member of a union)</p></blockquote><div>That's theoretically true, but all implementations (that I'm aware of at least) support this as implementation defined behavior.</div><blockquote type="cite"><p dir="ltr" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">- why not just use memcpy, the language-sanctioned way to do this operation?</p></blockquote></div>No idea, this just didn't occur to me, I'll make it so! Thanks David,<div><br></div><div>-Chris</div></body></html>