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

Extend validity checks for references and Box #3759

Open
Tracked by #3203
celinval opened this issue Dec 5, 2024 · 0 comments
Open
Tracked by #3203

Extend validity checks for references and Box #3759

celinval opened this issue Dec 5, 2024 · 0 comments
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@celinval
Copy link
Contributor

celinval commented Dec 5, 2024

  • A reference or Box must be aligned, it cannot be dangling, and it must point to a valid value (in case of dynamically sized types, using the actual dynamic type of the pointee as determined by the metadata). Note that the last point (about pointing to a valid value) remains a subject of some debate.

  • The metadata of a wide reference, Box, or raw pointer must match the type of the unsized tail:

    • dyn Trait metadata must be a pointer to a compiler-generated vtable for Trait. (For raw pointers, this requirement remains a subject of some debate.)
    • Slice ([T]) metadata must be a valid usize. Furthermore, for wide references and Box, slice metadata is invalid if it makes the total size of the pointed-to value bigger than isize::MAX.

https://doc.rust-lang.org/reference/behavior-considered-undefined.html

@celinval celinval changed the title Validity of references and Box Extend validity checks for references and Box Dec 5, 2024
@feliperodri feliperodri added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants