[cfe-dev] atomic intrinsics
Howard Hinnant
hhinnant at apple.com
Mon Oct 18 10:27:21 PDT 2010
On Oct 18, 2010, at 1:19 PM, John McCall wrote:
>> One question about Design A that has yet to be discussed is the possible defaulting of memory orderings in the intrinsics. This defaulting, if it exists, is described at the very bottom of:
>>
>> http://libcxx.llvm.org/atomic_design_a.html
>>
>> I have no strong feeling either way. I can easily live with or without the memory order defaults. But I should either remove the "If desired" from the description (mandating the defaults), or remove the description of the defaults altogether (banning them). Please weigh in with your opinions.
>
> The defaulting scheme for the two-parameter versions is very complicated and precludes implementing the type-checking for these builtins with a single C++ function declaration. If we're going to allow defaulting, I think they should both default to 5.
This would make it very easy to drop into undefined behavior. For example:
while (__atomic_compare_exchange_strong(&atomic_obj, &expected, desired, memory_order_acquire))
...
In the above example, only mem_failure is defaulted (to 5 as you suggest), and this violates the requirement that mem_failure <= mem_success (mem_success is 2).
-Howard
More information about the cfe-dev
mailing list