GCC Newspaper
JUNE 15, 2026
gcc Proposed

Builtins for C++26 integer atomic reductions

The author provides a detailed explanation with litmus tests demonstrating the necessity of new builtins for C++26 integer atomic reductions due to memory mode…

The author provides a detailed explanation of why new builtins are required for C++26 integer atomic reductions. They use litmus tests to demonstrate the memory model semantics that necessitate these new builtins. This discussion highlights the complexities of ensuring correct atomic operations in multi-threaded C++ code.

In Details

The discussion concerns the C++ memory model and the need for compiler builtins to correctly implement atomic reductions. The author uses litmus tests to illustrate how relaxed atomic loads and compare-and-swap (CAS) operations can lead to reordering issues around thread fences, necessitating new builtins to guarantee memory model semantics for C++26.

For Context

In concurrent programming, atomic operations are crucial for managing shared data accessed by multiple threads, preventing data races and ensuring consistency. The C++ memory model defines how these atomic operations behave, particularly regarding memory ordering. This proposal argues that existing atomic operations are insufficient for implementing certain reduction operations (e.g., incrementing a variable) under the C++26 standard, requiring new compiler builtins to guarantee correct behavior in multi-threaded scenarios. Litmus tests are small programs designed to expose subtle memory ordering issues.