GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

Libstdc++: Test ATOMIC_*_LOCK_FREE macros for <stdatomic.h>

This commit adds a test case for the ATOMIC_*_LOCK_FREE macros in <stdatomic.h>, ensuring compliance with the C++ standard.

This commit adds a new test case to verify the correctness of the ATOMIC_*_LOCK_FREE macros provided by the <stdatomic.h> header. The test is a copy of an existing test for with the header include adjusted to test the freestanding header provided by the C standard. This change ensures that the libstdc++ implementation adheres to the requirements of LWG 4480, which mandates the presence of ATOMIC_CHAR8_T_LOCK_FREE.

In Details

This change adds a test for LWG 4480, which requires <stdatomic.h> to provide ATOMIC_CHAR8_T_LOCK_FREE. The test is a copy of ../atomic/macros.cc with the header include changed. This ensures the C standard's atomic primitives behave as expected, even if the C++ version is subtly different.

For Context

The C++ standard library provides atomic operations, which allow multiple threads to safely access and modify shared data. The <stdatomic.h> header provides the same functionality for C. This commit adds a test to ensure that the ATOMIC_*_LOCK_FREE macros, which indicate whether atomic operations are lock-free, are correctly defined in the C standard library implementation. This ensures that C++ code using atomics behaves as expected across different platforms and compilers.

Filed Under: libstdc++testsuiteatomicsC++