Skip to content

Should std::slice::from_raw_parts document that slices larger than isize::MAX are unsound? #53676

Closed
@oconnor663

Description

@oconnor663

Indexing into a slice relies on ptr::offset, which says that its UB to use an offset/index larger than isize::MAX. As documented by ptr::offset, "memory acquired directly from allocators or memory mapped files may be too large to handle with this function." Does that mean that e.g. memory mapping a file larger than isize::MAX into a slice is unsound, because safe code can cause UB just by indexing into it? Should the from_raw_parts docs tell callers that they need to check this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions