Skip to content

compare_exchange_weak on AtomicUsize etc has inconsistent cfg-gating #54276

Closed
@mvirkkunen

Description

@mvirkkunen

Compare-and-swap methods on the atomic types in core::sync::atomic seem to be gated by #[cfg(target_has_atomic = "cas")] to only define them on targets that support CAS in hardware. However compare_exchange_weak isn't gated at all. This looks like an oversight, if the intention is to never define those methods if the target doesn't actually support them.

N.b. on at least the thumbv6m-none-eabi target, compare_exchange_weak compiles to calls to the same internal functions (__sync_val_compare_and_swap_4 and similar, presumably in compiler-rt or something) as compare_exchange.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions