-
Notifications
You must be signed in to change notification settings - Fork 58
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
Document in libstd where we rely on unspecified layout details #90
Comments
The |
I don't think that is what I meant. There are no I am asking for code making assumptions about how the compiler performs layout. Stuff like this, which makes assumptions about how slices are laid out (which we haven't guaranteed, AFAIK): pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
Repr { raw: FatPtr { data, len } }.rust
} |
My point was that the Maybe you can look for places where the standard library might assume niche optimizations that are not guaranteed, like, e.g., |
Or |
That's exactly what I was not asking for. :)
Yes! That's what I am asking for. Where does libstd do that?
Yes! We should make it |
See rust-lang/rust#62522 for another case of libstd relying on "magic". |
Here's a list by 0b_0101_001_1010 of a bunch of place where the standard library or compiler are making layout assumptions. They should be fixed via |
Closing as not having been a fruitful issue in 4 years and not being clearly opsem territory |
In rust-lang/rust#58582, the issue came up that libstd does things we do not permit user code to do: it relies on unspecified details of data type layout.
from_raw_parts
is a prime example of such code.It'd be great if we could clearly mark every occurrence of this with comments in the standard library. This is of course directly related to the previous discussion topic where we determined what we do and do not guarantee about data type layout -- the more we guarantee, the fewer such comments are needed.
We can use this issue to collect places that do rely on unspecified layout, and then hopefully someone can prepare a PR to add appropriate comments.
The text was updated successfully, but these errors were encountered: