-
Notifications
You must be signed in to change notification settings - Fork 28
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
UB with ThinVec::new
#24
Comments
Wait, do the aliasing rules apply to ZSTs? |
The same example still compiles and doesn't panic if you use Edit:
|
PS: if you think something is UB, consider running it under miri. It's not perfect but if miri's happy, that's a pretty good sign you're doing something fine. (See Tools > Miri in the top right) |
Now I feel silly, sorry about this |
The following code is unsound, yet compiles:
This triggers 2 forms of undefined behavior:
1.nevermind, see belowslice_a
andslice_b
are aliased mutable references.2.
slice_a
andslice_b
are mutable references created from a shared reference.ThinVec::new()
turns a&Header
into a*mut Header
, thenThinVec::as_mut_slice
creates a&mut [T]
from this pointerThe text was updated successfully, but these errors were encountered: