That's good to know. Something seemed funny about that cast and I figure it was a left over while the other sample conversion functions were updated. It's probably one of those things that worked fine for a long time but was never explicitly allowed to work. Reminds me of parts of Pd. :)
I'm not super familiar with C++14 & C++20, so it's good to know.
On Feb 9, 2020, at 2:29 AM, pd-dev-request@lists.iem.at wrote:
Message: 1 Date: Sun, 9 Feb 2020 02:29:49 +0100 From: Christof Ressi <info@christofressi.com mailto:info@christofressi.com> To: pd-dev@lists.iem.at mailto:pd-dev@lists.iem.at Subject: Re: [PD-dev] Tips on debugging dip crashes? Message-ID: <f1514d4a-dc01-cb71-f271-98e53ca7a629@christofressi.com mailto:f1514d4a-dc01-cb71-f271-98e53ca7a629@christofressi.com> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
by applying a union used in one part of the code to another to
replace a dereferencing cast
Type punning via pointer casts often violates the "strict aliasing rules" and the compiler might do wonky optimizations. Type punning via unions, on the other hand, is explicitly allowed in C. It is *not* allowed in C++, although in practice I haven't encountered a case where it didn't work. (The legal way to do type punning in C++ has been memcpy() , which gets fully optimized away; C++20 finally has std::bit_cast()).
You probably know this anyway. Just writing for other people who are reading :-)
Christof
-------- Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/