2 ms·
The underlying problem is that memory access is slow, allocating registers is hard (so we let the compiler do it) and compilers don't always know what you're do
by toast0 8y ago
The underlying problem is that memory access is slow, allocating registers is hard (so we let the compiler do it) and compilers don't always know what you're doing with memory.
So, in order to generate faster programs, compilers are getting more and more agressive about reusing data that has already been copied into registers, hiding under the shadows of 'undefined behavior.' The standard doesn't indicate a defined way to mess with this data so I'll just keep using the copy I have.
Writing through an untracked pointer probably convinced the compiler to dump its register caches.
C used to be thought of as kind of a portable assembly language, but when the compiler is doing all these optimizations, there's a lot of room for clashing.