Skip to content

What is the UB behaviour of accessing *mut through &T #1227

Closed
@EvanTheB

Description

@EvanTheB

* Mutating immutable data. All data inside a [`const`] item is immutable. Moreover, all

Mutating immutable data. All data inside a const item is immutable. Moreover, all data reached through a shared reference or data owned by an immutable binding is immutable, unless that data is contained within an UnsafeCell.

I was wondering how to use *mut pointers in more safe way, I asked this question: https://stackoverflow.com/questions/72541045

A user responded that I read this paragraph wrong, and that modifying data through both UnsafeCell<U> AND *mut U would not be UB. Does the above paragraph need to mention raw pointers?

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