6.55 Built-in Functions for Memory Model Aware Atomic Operations

Amar Memic amemic@uni-osnabrueck.de
Wed Jul 21 08:20:32 GMT 2021


Hi,6.55 Built-in Functions for Memory Model Aware Atomic Operations (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html)  says:Note that the ‘__atomic’ builtins assume that programs will conform to the C++11 memory model. In particular, they assume that programs are free of data races. See the C++11 standard for detailed requirements.

I think the second sentence is a bit misleading because atomics should handle data races.
Especially, interleaving read/write or write/write operations should be well-defined.
If you assume that programs are free of data races, then you could not implement spinlock based on these atomics, for example.
I hope you can help me to interpret the paragraph in the right manner. 

Thanks in advance
Amar Memic


More information about the Libstdc++ mailing list