7 ms·
The first line is already UB. `assume_init` requires the contents to be initialized, hence the name.
by artikae 2y ago
The first line is already UB. `assume_init` requires the contents to be initialized, hence the name.
- rectang 2y agoMmm, I went back and read the docs for MaybeUnit more carefully and that's a good point. It may be better to just leave the assignment off the declaration. If the variable is read before it's initialized to something, we'll get a Rust compilation error, forcing programmer intervention. Detecting actual bugs that would result in memory errors and forcing them to be resolved is very much in the spirit of Rust. TRACTOR may aspire to gift C programs with memory safety for free, but it won't always be possible. Of course if TRACTOR can determine through static analysis that the unitialized read can't cause problems, it might emit different code.