Added warning around code with reference to uninit bytes

This commit is contained in:
Daniel Henry-Mantilla 2019-09-03 12:17:03 +02:00
parent 815dec9db1
commit 23c76ff7b9

View File

@ -371,6 +371,14 @@ where
loop {
if g.len == g.buf.len() {
unsafe {
// FIXME(danielhenrymantilla): #42788
//
// - This creates a (mut) reference to a slice of
// _uninitialized integers_.
//
// - This having defined behavior is **unstable**:
// it could become UB in the future,
// at which point it would have be changed.
g.buf.reserve(reservation_size(r));
let capacity = g.buf.capacity();
g.buf.set_len(capacity);