Skip to content

Ordering::AcqRel implementation contradicts the docs #49127

Closed

Description

@imp

Documentation on Ordering::AcqRel states:

AcqRel
When coupled with a load, uses `Acquire` ordering, and with a store `Release` ordering.

However, this code

use std::sync::atomic::{AtomicBool, Ordering};

fn main() {
    let b = AtomicBool::new(false);
    b.store(true, Ordering::AcqRel);
    b.load(Ordering::AcqRel);
}

panics on both store and load (if the call to store() is commented out)

thread 'main' panicked at 'there is no such thing as an acquire/release store', /checkout/src/libcore/sync/atomic.rs:1482:19
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Either documentation should be updated to describe why this is not relevant to store/load, or implementation should be fixed to actually deliver on the promise.

Activity

  1. hanna-kruppe commented on Mar 18, 2018

    @hanna-kruppe
    Contributor

    The implementation is correct. AcquireRelease is an ordering for operations that both load and store. If you just have a load or a store, you can and should simply use acquire or release respectively.

  2. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
    on Mar 18, 2018
  3. imp commented on Mar 18, 2018

    @imp
    ContributorAuthor

    Ok, makes sense. Then the documentation should reflect that more clearly.

  4. added a commit that references this issue on Mar 26, 2018
    a81aeaa
  5. added a commit that references this issue on Mar 26, 2018
    9e4d5cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions