You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f(std::atomic<int> volatile&):
mfence
mov eax, dword ptr [rdi]
ret
as does the equivalent C program.
This is surprising, because only a load instead of a RMW operation is emitted. fetch_add is always a RMW operation on the abstract machine, even if the stored value is the same as the one loaded, and the expectation would be that volatile preserves this semantic.
This may or may not be a conformance issue. The standards seem to be unclear about the interpretation of "access" with regards to volatile-qualified RMW operations.
f(std::atomic<int> volatile&):
mfence
mov eax, dword ptr [rdi]
ret
as does the equivalent C program.
This is surprising, because only a load instead of a RMW operation is emitted. fetch_add is always a RMW operation on the abstract machine, even if the stored value is the same as the one loaded, and the expectation would be that volatile preserves this semantic.
This may or may not be a conformance issue. The standards seem to be unclear about the interpretation of "access" with regards to volatile-qualified RMW operations.
The C++ test case
on Clang 18.1.0 x86-64 with -O1 produces
as does the equivalent C program.
This is surprising, because only a load instead of a RMW operation is emitted.
fetch_add
is always a RMW operation on the abstract machine, even if the stored value is the same as the one loaded, and the expectation would be thatvolatile
preserves this semantic.This may or may not be a conformance issue. The standards seem to be unclear about the interpretation of "access" with regards to
volatile
-qualified RMW operations.See discussion at https://stackoverflow.com/questions/78776735/semantics-of-volatile-stdatomict and https://stackoverflow.com/questions/78777076/semantics-of-volatile-atomic.
The text was updated successfully, but these errors were encountered: