-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Infinite loop when trying to fill a Vector of MaybeUninit<SomeZeroSizedType> #80747
Comments
Note that since I wonder if |
@SkiFire13 oh yes, if I change unsafe{v.set_len(v.capacity())}; to unsafe{v.set_len(3)}; then the code works fine, so I guess it's fair to say that there are no bugs! However, it is true that it's surprising that I'm willing to do a PR adding that to the doc. |
Trying to reproduce this, but |
document capacity for ZST as example The main text already covers this, although it provides weaker guarantees, but I think an example in the right spot does not hurt. Fixes rust-lang#80747
Rollup merge of rust-lang#136293 - hkBst:patch-32, r=Amanieu document capacity for ZST as example The main text already covers this, although it provides weaker guarantees, but I think an example in the right spot does not hurt. Fixes rust-lang#80747
document capacity for ZST as example The main text already covers this, although it provides weaker guarantees, but I think an example in the right spot does not hurt. Fixes rust-lang#80747
I tried to reduce the demonstration to the minimum possible.
I wrote a function that fills a vector of
MaybeUninit<T>
values that I think is safe (free of UB).The code works well with
cargo miri run
.But when calling this function with a zero-sized type, the execution goes into an infinite loop.
The exact same code without the
MaybeUninit
logic works as expected.Here is the code:
(Playground)
Output:
The text was updated successfully, but these errors were encountered: