Skip to content

Addressing a Share static mut should be safe #13232

Closed
@alexcrichton

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.

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