C++20's Strongly Happens Before: Untangling the Memory Model
2025-09-01
This article delves into C++20's newly introduced "strongly happens before" relationship, which solves a tricky problem within the C++ memory model. Using a simple multithreaded program example, the author progressively explains how modification order, coherence ordering, and the "strongly happens before" relationship constrain the order of concurrent execution. The article also analyzes why certain executions seemingly violating the C++ memory model are allowed on Power architectures and explains how "strongly happens before" fixes these inconsistencies, ultimately guaranteeing a single total order for all `memory_order::seq_cst` operations.
Read more
Development