Skip to content

Lift unnecessary restriction on CAS failure ordering #68464

Closed
@tmiasko

Description

@tmiasko

Currently compare_exchange requires the failure ordering to "be equivalent to
or weaker than a success ordering". On the other hand C11/C++11 requires only
that "failure shall be no stronger than the success", which arguably means that
one can write e.g. compare_exchange(..., Release, Acquire) in C/C++ but not in Rust.

Arguably, because neither C11 standard nor C++11 standard defines what it means
for an ordering to be stronger from another. When the issue was raised in
LWG2445, the proposed and accepted resolution was to lift those restrictions
altogether, leaving only requirement that "the failure argument shall not be
memory_order_release nor memory_order_acq_rel".

It would be beneficial to remove success/failure ordering restrictions for
reasons described in C++ proposal P0418r2.

EDIT: Restrictions were lifted in clang & LLVM:

Metadata

Metadata

Assignees

Labels

A-concurrencyArea: ConcurrencyC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-langRelevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions