Hacker News new | past | comments | ask | show | jobs | submit login

Obviously, initialized memory isn't an uninitialized memory any more.

There are fun edge cases here. Writing to memory through `&mut T` makes it initialized for T, but its padding bytes become de-initialized (that's because the write can be a memcpy that also copies the padding bytes from a source that never initialized them).




Note that if you have a `&mut T` then the memory must already be initialized for T, so writing to that pointer doesn't initialize anything new (although as you say it can deinitialize bytes, but that only matters if you use transmute or pointer casting to get access to those padding bytes somehow).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: