News for hackers. Stuff that matters.
Re:The Lost Art of Structure Packing (2018) by jcelerier on Monday April 27, 2020 @12:52PM (#22997555)
> First of all, there is no way the compiler is going to optimize a call to memset(&foo, 0, sizeof(foo)) when &foo is being interpreted as a void pointer. That doesn't even make sense.

that is really dangerous to assume. memset is a compiler built-in in every relevant C++ compiler and the compiler definitely knows the type of the object that is behind your void* and knows if you're being nasty.

e.g. look at this code : https://gcc.godbolt.org/z/xh9BXs

it's UB, and the compiler knows it and inserts an "invalid opcode" instruction even if you try to hide a memset behind a void*-taking function

Re:The Lost Art of Structure Packing (2018) by saagarjha on Monday April 27, 2020 @01:32PM (#22997948)
-Ofast makes non-compliant programs anyways, so it's not the best example.
Re:The Lost Art of Structure Packing (2018) by jcelerier on Monday April 27, 2020 @01:56PM (#22998192)
I had -Ofast in there but you can check that it's the same with -O2