On Sat, Apr 6, 2019 at 10:06 AM Christof Ressi christof.ressi@gmx.at wrote:
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.
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: uint8_t bytes[4] = {12, 34, 56, 78}; float f = *(float*)bytes; But isn't that basically the same as what memcpy does?
Martin