5 ms·
(i.e. treating bytes of memory as some object through a reinterpret_cast away from char ).* That's how people have used C and C++ for decades in low-level work
by userbinator 7y ago
(i.e. treating bytes of memory as some object through a reinterpret_cast away from char ).*
That's how people have used C and C++ for decades in low-level work, and it still works exactly as you'd expect, so stop saying "don't do it" because you're only encouraging the compiler-writer-UB-optimisation-nonsense crowd to make things even worse. It's already bad enough that they think the Holy Standard is the only thing that matters.
I believe Linus has several memorable rants on this topic already.
- pingyong 7y agoDoesn't matter anymore, Clang and GCC will both make any and all optimizations they can find by assuming you will never hit UB, including just erasing all UB code. You can dislike it, but that's just the reality now, and ignoring it won't make it go away. The only way to change it would be a change in the standard.