Before revision: The GNU inline assembler statement asm volatile("" ::: "memory"); or even __asm__ __volatile__ ("" ::: "memory"); forbids GCC compiler to reorder read and write commands around it .GCC compiler-gcc.h The C11/C++11 function atomic_signal_fence(memory_order_acq_rel); forbids the compiler to reorder read and write commands around it.
After revision: Any of these GNU inline assembler statements forbids the GCC compiler to reorder read and write commands around it:GCC compiler-gcc.h asm volatile("" ::: "memory"); or even __asm__ __volatile__ ("" ::: "memory"); This C11/C++11 function forbids the compiler to reorder read and write commands around it .GCC compiler-gcc.h : atomic_signal_fence(memory_order_acq_rel);