Re:Why Is SQLite Coded in C and not Rust
by rileymat2 on Wednesday October 15, 2025 @04:10PM
(#45597781)
There is more than undefined behavior, if I was to define using an uninitialized variable as yielding whatever data was previously in that location, it is well defined but unsafe.
[ Parent
| on HN ]
Re:Why Is SQLite Coded in C and not Rust
by oconnor663 on Wednesday October 15, 2025 @08:22PM
(#45600086)
That could be well defined for POD types like arrays of bytes (I think in that case they call it "freezing"), but you'd still have undefined behavior if the type in question contained pointers. Also at least in Rust it's UB to create illegal values of certain types, like a bool that's anything other than 0 or 1.
Which is all kind of to say, all of Rust's different safety rules end up being surprisingly densely interconnected. It's really hard to guarantee one of them (say "no use-after-free") without ultimately requiring all of them ("no uninitialized variables", "no mutable aliasing", etc).