Is multi-threading in C++ safe? Will assertions fail?
Case Case1: According to the gcc documentation the following assertion will not fail https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync -Thread 1- x.store (1, memory_order_relaxed) x.store (2, memory_order_relaxed) -Thread 2- y = x.load (memory_order_relaxed) z = x.load (memory_order_relaxed) assert (y <= z) The assert cannot fail. Once the store of 2 is seen by thread 2, it can no longer see […]