The bundled <atomic> (lli/runtime-include/c/atomic) defines std::atomic but not std::atomic_ref, so C++20 code that uses it does not compile. The header looks like a pre-C++20 copy of libc++'s, so __cpp_lib_atomic_ref is never defined even at -std=c++23, while __cplusplus is correct.
Reproducer:
#include <atomic>
#include <cstdint>
static std::uint32_t word = 0;
int main() {
std::atomic_ref<std::uint32_t> r{word};
r.store(1, std::memory_order_release);
return 0;
}
$ genmc -- -std=c++23 aref.cpp
error: no member named 'atomic_ref' in namespace 'std'
Same result at -std=c++20.
The machinery underneath appears to be there already. Replacing atomic_ref with __atomic_* builtins on the same plain variable verifies fine, and GenMC correctly reports a race on the data when the release on a compare-exchange is weakened to relaxed, so this looks like a missing declaration rather than a missing capability.
This matters for code that uses atomic_ref deliberately, where a field must stay a plain type with a fixed layout and only some accesses to it are atomic. Such code cannot be checked as written today.
Version: GenMC v0.17.0 (commit #29b03a6), built with LLVM 18.1.8, on Linux.
Happy to put together a patch adding atomic_ref over the existing __c11_atomic_* wrappers if that would be welcome. Worth saying that the rest of the C++20 atomic surface is missing too (atomic_flag::test, wait/notify), so let me know whether you would rather have the one class or the wider gap addressed.
The bundled
<atomic>(lli/runtime-include/c/atomic) definesstd::atomicbut notstd::atomic_ref, so C++20 code that uses it does not compile. The header looks like a pre-C++20 copy of libc++'s, so__cpp_lib_atomic_refis never defined even at-std=c++23, while__cplusplusis correct.Reproducer:
Same result at
-std=c++20.The machinery underneath appears to be there already. Replacing
atomic_refwith__atomic_*builtins on the same plain variable verifies fine, and GenMC correctly reports a race on the data when the release on a compare-exchange is weakened to relaxed, so this looks like a missing declaration rather than a missing capability.This matters for code that uses
atomic_refdeliberately, where a field must stay a plain type with a fixed layout and only some accesses to it are atomic. Such code cannot be checked as written today.Version: GenMC v0.17.0 (commit #29b03a6), built with LLVM 18.1.8, on Linux.
Happy to put together a patch adding
atomic_refover the existing__c11_atomic_*wrappers if that would be welcome. Worth saying that the rest of the C++20 atomic surface is missing too (atomic_flag::test,wait/notify), so let me know whether you would rather have the one class or the wider gap addressed.