Displaying 2 results from an estimated 2 matches for "atomic_int".
Did you mean:
atomic_inc
2012 Aug 03
3
[LLVMdev] Is it correct to access non-atomic variables using atomic operations?
Hi Everyone,
This might be more a C/C++11 question than a LLVM question: I wondering if it is semantically correct to access an ordinary variable via atomic operations, like:
int val;
void foo(){ atomic_store((atomic_int *)(&val), 42); }
I tried this simple program on clang+llvm and 42 seems to be correctly stored to val. But, is this just by luck or a right way to go?
Thanks.
- Lei
2012 Aug 03
0
[LLVMdev] Is it correct to access non-atomic variables using atomic operations?
...12:11 AM, Lei Zhao <leizhao833 at gmail.com> wrote:
> Hi Everyone,
>
> This might be more a C/C++11 question than a LLVM question: I wondering if it is semantically correct to access an ordinary variable via atomic operations, like:
>
> int val;
> void foo(){ atomic_store((atomic_int *)(&val), 42); }
>
> I tried this simple program on clang+llvm and 42 seems to be correctly stored to val. But, is this just by luck or a right way to go?
Like with nearly all type punning, alias analysis is likely to eat
your program if you do this.
In LLVM itself, atomic operations...