As the title, when we write ++a
in C/C++
, it seems the compiler may compile it as:
inc dword ptr[i]
which is atomic, or:
mov eax, dword ptr[i]
inc eax
mov dword ptr[i], eax
which is not atomic.
Is there any advantage to compile it as non-atomic style?