UB in Rust vs C
UB in Rust vs C
Posted Aug 16, 2024 0:05 UTC (Fri) by tialaramex (subscriber, #21167)In reply to: UB in Rust vs C by ralfj
Parent article: Standards for use of unsafe Rust in the kernel
I assume Rust-for-Linux is in practice never compiled in debug mode, if so as we start to see some more Linux developers with C experience deciding to write some Rust it will be important to correct the C instinct to assume that adding N in the usual way "just wraps" because in practice adding N really does just wrap in Rust (because by default the optimized build wraps on overflow), but as you say it's a bug to overflow, you should explicitly write what you meant even though that produces the same machine code, it makes maintenance much more robust.
