3 ms·
I thought the idea was that Rust’s behavior in cases of overflow was defined, whereas c/c++ is not defined by the language.
by laweijfmvo 4y ago
I thought the idea was that Rust’s behavior in cases of overflow was defined, whereas c/c++ is not defined by the language.
- tialaramex 4y agoThe C language says the unsigned integers wrap. That is, C's 8-bit unsigned integer (e.g. uint8_t or in Linux source u8) behaves the same as Rust's Wrapping<u8> type. In Rust the u8 type wraps in default release builds, but panics on overflow in debug builds, but this is kernel code so it will definitely be built in release mode with wrapping.