Conversation

In Rust, both signed and unsigned integer overflow is always considered a bug. Intended overflows need to be marked and it supports wrapping for both signed and unsigned via the appropriate APIs. It traps for unintended overflows in debug builds by default and can in production.
3
2
This Tweet was deleted by the Tweet author. Learn more
This Tweet was deleted by the Tweet author. Learn more
Rust has better support for wrapping integer arithmetic than C, since it has portable signed wrapping not requiring an opt-in compiler extension like -fwrapv. The reason it's not the default is because it's rarely intended, so it makes unintended overflows far harder to find.
1
1
Modular arithmetic is used in cryptography, and that still works just fine. It's just explicitly written to use modular arithmetic. Being explicit about this is a positive. Also, uses for modular arithmetic often don't want the mod to be based on fixed-size integer widths anyway.
1