https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103966
--- Comment #2 from Witold Baryluk <witold.baryluk+gcc at gmail dot com> ---
Similarly, dec, add, sub, are affected, as well mul.
Example:
#include <atomic>
#include <cstdint>
uint64_t x;
void add_a() {
x += 5;
}
std::atomic<uint64_t> y;
void add_b_non_atomic() {
y.store(y.load(std::memory_order_relaxed) + 5, std::memory_order_relaxed);
}
Producing:
add_a():
add QWORD PTR x[rip], 5
ret
add_b_non_atomic():
mov rax, QWORD PTR y[rip]
add rax, 5
mov QWORD PTR y[rip], rax
ret
y:
.zero 8
x:
.zero 8