Skip to content

Conflicting documentation on the alignment requirements for ptr::copy #62313

Closed

Description

The docs for ptr::drop_in_place state:

Unaligned values cannot be dropped in place, they must be copied to an aligned location first:

And include an example which uses ptr::copy to copy the value from an unaligned pointer into an aligned one. However, the docs for ptr::copy state:

Both src and dst must be properly aligned.

Either the docs for ptr::copy are wrong, and src does not need to be aligned, or the example for drop_in_place invokes UB and should be updated to use read_unaligned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.T-langRelevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions