<div dir="ltr"><div dir="ltr">On Sat, Apr 6, 2019 at 10:06 AM Christof Ressi <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">While type punning through unions is allowed in C, the only way which works in both C and C++ (without breaking the strict aliasing rule) is using memcpy. In such case, the call to memcpy will completely optimized away by every decent compiler.<br>
<br></blockquote><div><br></div><div>But Pd is written in c, so no problem. How does the memcpy thing work? It is also ANSI c. To m it looks just as 'dangerous' as the union method, which I wouldn't call type-punning. 'Raw' type punning would be like:<br></div><div>uint8_t bytes[4] = {12, 34, 56, 78};</div><div>float f = *(float*)bytes;</div><div>But isn't that basically the same as what memcpy does?<br></div><div><br></div><div><br></div><div>Martin</div><br></div></div>