[swift-dev] Questions about ARC

Joe Groff jgroff at apple.com
Fri Dec 2 11:13:51 CST 2016

> On Dec 1, 2016, at 4:55 PM, Jiho Choi via swift-dev <swift-dev at swift.org> wrote:
> Thanks for the explanation.
> One last question is why non-atomic ARC operations still use atomic load and store.  Wouldn't regular memory operations be enough?

According to the C++ memory model, all operations on an atomic<T> must be atomic. It is undefined behavior to cast a pointer to the atomic into a T* and perform normal loads and stores. "Relaxed" loads and stores however imply no ordering with other threads, so compile down to plain nonatomic CPU instructions.


More information about the swift-dev mailing list