bumpalo icon indicating copy to clipboard operation
bumpalo copied to clipboard

`Vec::set_len` example is UB

Open zetanumbers opened this issue 2 years ago • 2 comments

While i hope it's not, it seems intentional. If it is... why? https://github.com/fitzgen/bumpalo/blob/fa52577688284d73b44cc8f49671ef02ebdea14b/src/collections/vec.rs#L1028-L1042

zetanumbers avatar Jun 27 '22 16:06 zetanumbers

Basically deref_mut happens inside of the Vec::drop, so the &mut [char] is created to uninitialized memory.

zetanumbers avatar Jun 27 '22 17:06 zetanumbers

I think this was taken from std but it looks like std's example is different now (if it was actually taken from there).

Happy to receive a PR to fix this, as docs/examples definitely shouldn't be this eggregiously wrong.

fitzgen avatar Jun 27 '22 19:06 fitzgen