3 ms·
I think compilers are free to reorder code at compile time assuming single-threaded execution, exposing the same bugs that memory ordering exposes at runtime. I
by nyanpasu64 3y ago
I think compilers are free to reorder code at compile time assuming single-threaded execution, exposing the same bugs that memory ordering exposes at runtime. I'm not sure if MSVC does this or not.
- xxpor 3y agoThere are a lot of details, but essentially yes. To solve that, see the compiler barriers section in https://www.kernel.org/doc/Documentation/memory-barriers.txt https://www.kernel.org/doc/Documentation/memory-barriers.txt