Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Representation guarantee? #21

Open
Rua opened this issue Jun 16, 2024 · 1 comment
Open

Representation guarantee? #21

Rua opened this issue Jun 16, 2024 · 1 comment

Comments

@Rua
Copy link

Rua commented Jun 16, 2024

Is there a guarantee that Aligned<A, T> has the same memory representation as T, and is thus sound to transmute to T?

@MabezDev
Copy link
Member

My understanding is:

  • The alignment struct is repr(C)
  • ZSTs are ignored when a struct is repr(C)
  • Alignment is ensured via a ZST array.
  • The layout should therefore be the same as if it were T itself

I am not the original author of the library, so this might not be correct. In practice, however, this is how it works with current versions of the Rust compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants