Skip to content

Addressing a Share static mut should be safe #13232

Closed

Description

@alexcrichton

We talked about this at the most recent workweek, but I believe this code should compile as-is:

use std::sync::atomics;

static mut CNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;

fn main() {
    CNT.fetch_add(1, atomics::SeqCst);
}

Specifically, you should be allowed to take the address (&-pointer) of a static mut, and you should continue to need unsafe to take a &mut-pointer to a static mut.

Activity

  1. alexcrichton commented on Mar 31, 2014

    @alexcrichton
    MemberAuthor
  2. alexcrichton commented on Mar 31, 2014

    @alexcrichton
    MemberAuthor

    Nominating.

  3. self-assigned this
    on Mar 31, 2014
  4. flaper87 commented on Mar 31, 2014

    @flaper87
    Contributor

    Makes sense to me! Assigning myself to this issue.

  5. pnkfelix commented on Apr 3, 2014

    @pnkfelix
    Contributor

    Marking P-low, not on 1.0 milestone. (We can add this backwards compatibly, at least if one ignores lints.)

  6. 10 remaining items

  7. flaper87 commented on Mar 23, 2015

    @flaper87
    Contributor

    Bug fixed by 4c62486

  8. added a commit that references this issue on Sep 20, 2022
  9. added a commit that references this issue on Aug 8, 2024
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions