-
Notifications
You must be signed in to change notification settings - Fork 269
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
preallocated_*
promotes unsoundness
#665
Comments
Great catch! And I like your solution (assuming it is possible to do all the conversions we want :)) |
You're right :) |
Yeah, I remember that MSRV at some point didn't include Now I realized that maybe we should take |
These methods take
&mut [AlignedType]
which must be initialized because it does not containMaybeUninit
. The API may entice people to write this code though:This is unsound and it's not obvious. (The whole maybe uninit business is subtle and not widely understood by people.)
I was thinking about making it accept
&mut [MaybeUninit<AlignedType>]
but that may be annoying for consumers and promotes casting&mut T
to&mut MaybeUninit<T>
which, while not unsound itself, needs to be treated carefully. So the only sane option that I can think of is definingAlignedType
asstruct AlignedType(MaybeUninit<[u8, 16]>)
, providing conversions from pointers/MaybeUninit<[AlignedType]>
and documenting that it's fine to have it uninitialized.The text was updated successfully, but these errors were encountered: