Description
With clang 17.1 on ARM64 I'm seeing std::atomic<T>::is_always_lock_free
evaluate to true
even though the member function std::atomic<T>::is_lock_free()
evaluates to false
for the same type.
Here's a minimal example:
#include <atomic>
#include <cstdint>
#include <iostream>
struct bigint_equiv {
uint64_t first, second;
};
int main() {
std::atomic<bigint_equiv> a;
std::cout << a.is_lock_free() << " " << decltype(a)::is_always_lock_free << std::endl;
}
Possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70814 where the gcc devs discuss why libatomic doesn't allow 128 bit atomics to be lock-free on ARM.
When I compile the same code with gcc 13.2 is_always_lock_free
is false
which is strange since I've confirmed that the same libstdc++ is being included and linked. This also appears to be what happens on godbolt too though. With gcc the assembly (as best I can tell) shows a 0 being written out (https://godbolt.org/z/T7493K8xP) while with clang the assembly shows a 1 (https://godbolt.org/z/Gb35jMfjr).