Skip to content

Representation of and operations on pointers and usize #251

Open
@mahkoh

Description

@mahkoh

I have a few questions regarding usize and raw pointers for sized T:

  1. Is usize guaranteed to have the same layout as one of the uN?
  2. Is usize guaranteed to have no padding bits?
  3. Is usize as *mut T as usize the identity function on usize?
  4. Is usize as *mut T guaranteed to be the same as transmute::<usize, *mut T>?
  5. Is ptr::read_unaligned::<*mut T> safe for all arguments for which ptr::read_unaligned::<[u8; sizeof(*mut T)]> is safe?
  6. Is usize-literal as *mut T guaranteed to have no special behavior? (e.g. for 0usize)

The current documentation

does not answer these questions afaict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: Supporting a user to solve a concrete problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions