Skip to content

Array lifetime and type #1

Closed
Closed
@bluss

Description

@bluss

This is some drive by code review as requested 😄

Issue 1) It looks like the code is not correctly connecting the lifetime of the borrow of the slice with the lifetime that belongs to the reference that comes from the transmute. Here's a testcase that shows an aliasing violation.. we can mutate the data while we have a reference to it!

By the way, for pointers, prefer just using casts instead of transmuting. The same caveat with lifetimes still applies though.

The best way to make sure the lifetimes match up is using a function. For example like copy_lifetime, a function you can copy.

Issue 2) Unrestricted transmute. The user's type parameter is trusted, and the user can get bogus results by giving the wrong type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions