3 ms·
C/C++ doesn't emit them at all unless you ask it to. At least on x86-like architectures. It might have to on ARM because of its weak memory model? I'm not sure
by adastra22 3y ago
C/C++ doesn't emit them at all unless you ask it to. At least on x86-like architectures. It might have to on ARM because of its weak memory model? I'm not sure about that. But the C++ standard does basically zilch with respect to thread safety unless you use the appropriate memory fence compiler directives.
- estebank 3y agoWhat memory fences does the Rust compiler emit without you asking?
- adastra22 3y agoThe Rust compiler won’t compile code that mutates shared state unless there are appropriate memory fences. It makes you insert these barriers for correctness.
- heinrich5991 3y agoCan you give an example? I think relaxed atomics don't have memory fences.