Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first line is already UB. `assume_init` requires the contents to be initialized, hence the name.


Mmm, 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.




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

Search: