3 ms·
> Why is it important to initialize memory to 0's before we use it? Because reading from unitialized memory yields an indeterminate value. Operating on such a
by demindiro 4y ago
> Why is it important to initialize memory to 0's before we use it?
Because reading from unitialized memory yields an indeterminate value. Operating on such a value can lead to UB. This applies to languages other than Rust too (e.g. C).
Ralf explains it better than me[1].
[1]: https://www.ralfj.de/blog/2019/07/14/uninit.html https://www.ralfj.de/blog/2019/07/14/uninit.html