News for hackers. Stuff that matters.
Re:Catching integer overflows in C by AstralStorm on Wednesday August 22, 2018 @03:53AM (#17817093)
The right equivalent is actually punning through char* and enforcing lack of simultaneous aliasing. This is explicitly allowed in C++11.

Memcpy is a cost. Do it only when you actually need a copy.

Re:Catching integer overflows in C by saagarjha on Wednesday August 22, 2018 @04:05AM (#17817135)
All half-decent compilers elide a memcpy when you're using it for this purpose; they'll just generate the assembly you "intended" to create. And while I know casting to a char * is legal for all types, I don't believe casting from a char * is legal unless the memory the pointer references is actually the type you're casting to. I'll have to check on this–or if you have a link to the standard on this I can just look at that.