Re:Cross-platform Rust rewrite of the GNU coreutils
by Dylan16807 on Tuesday March 22, 2016 @08:04PM
(#11340977)
You're right, in certain cases it would still cause trouble, but it would be a lot fewer cases than 100%. Reading only once would be safe, and passing it to another functions would make a variable that can no longer change unexpectedly.
Re:Cross-platform Rust rewrite of the GNU coreutils
by dbaupp on Tuesday March 22, 2016 @08:51PM
(#11341256)
Unless the function is inlined/the compiler can deduce that the variable is undef.
(Of course, you could define it to work, but I would suspect that would make this sort of value much less useful.)
This is approximately what LLVM describes undef as, and it indeed leads to nasal demons. This description enables a single value to both pass a bounds check, and then subsequently go out of bounds!