Issue |
84802
|
Summary |
atomic_is_always_lock_free provides inconsistent results on Apple
|
Labels |
compiler-rt
|
Assignees |
|
Reporter |
ldionne
|
For a struct of size 16, `atomic_is_always_lock_free` seems to provide inconsistent results based on the address we're passing to the builtin. This seems odd since `is_always_lock_free` should tell us whether *any* instance of that type is lock free, regardless of its address?
```c++
// clang++ x.cpp -std=c++20 -o a.out && ./a.out
#include <iostream>
template <size_t N>
struct Sized { char x[N]; };
template <class T>
void test() {
std::cout << "sizeof(" << typeid(T).name() << ") = " << sizeof(T) << std::endl;
std::cout << "__atomic_always_lock_free(" << typeid(T).name() << ") = " << __atomic_always_lock_free(sizeof(T), 0) << std::endl;
T x;
std::cout << "__atomic_always_lock_free with ptr(" << typeid(T).name() << ") = " << __atomic_always_lock_free(sizeof(T), &x) << std::endl;
std::cout << "__atomic_is_lock_free(" << typeid(T).name() << ") = " << __atomic_is_lock_free(sizeof(T), &x) << std::endl;
}
int main() {
test<Sized<16>>();
}
```
Output:
```
$ clang++ x.cpp -std=c++20 -o a.out && ./a.out
sizeof(5SizedILm16EE) = 16
__atomic_always_lock_free(5SizedILm16EE) = 1
__atomic_always_lock_free with ptr(5SizedILm16EE) = 0
__atomic_is_lock_free(5SizedILm16EE) = 0
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs