Skip to content

Implement FromBytes and AsBytes for raw pointers #170

Closed
@joshlf

Description

@joshlf

Moved to #1818.

Historically, we've avoided adding these impls for fear that they could present a footgun, making it easier to accidentally transmute into a type, breaking its safety invariants.

Today, I was working on replacing some unsafe code in Fuchsia's Starnix project with zerocopy, and ran into some structs for which I can't derive FromBytes or AsBytes because they contain raw pointers. Currently, the lack of impls on raw pointers is entirely preventing this unsafe code from being replaced by zerocopy, which feels to me like throwing the baby out with the bathwater. IMO, it's more important to unlock this use case than to avoid a minor and theoretical footgun.

Note that, while the layout of raw pointers is well-defined, it's less clear that their bit validity is well-defined.

TODO:

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