-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ptr::read and ptr::write (and others?) should specify alignment requirements in their contract #36450
Comments
ping @Amanieu |
Also keep in mind that |
That then should be explicitly specified also, because it is definitely not a part of the C memcpy semantics. |
Maybe it's obvious in this discussion, but |
@bluss That's also never documented, to be clear, except in the not-right-places in the nomicon. |
Seems to be fixed, the documentation says:
and similarly for |
Recommend closing as fixed. |
copy{,_nonoverlapping} don't have mention of alignment in the documentation still. |
That's because it has none. |
@Amanieu above disagrees... |
The linked RFC (by @Amanieu) states that it uses |
I had the mistaken impression that |
Okay, so this appears to be a documentation issue -- we need to update |
The docs team discussed this today. Here's the current state of the
Basically, to really close this issue it would be prudent to go over every function in Since #29371 is still open, i'm considering this issue part of that one. |
@steveklabnik. This was completed in #53783. All functions in |
Thank you! |
Currently, these functions do not say anything about whether the raw pointer has to be aligned. They are also currently implemented with copy_nonoverlapping, which means they are safe to use with unaligned data. However, @ubsan tells me that this is an implementation detail that cannot be relied on.
In any case, these functions should explicitly specify their alignment requirements. Similarly, ptr::copy{,_nonoverlapping} also should do that, since right now they do not explicitly state that in their contract either. (They do reference C's memcpy and memmove, but I don't think that a C reference is a good way to define normative semantics.)
The text was updated successfully, but these errors were encountered: