Project for porting C to Rust gains Mozilla's backing (InfoWorld)
Project for porting C to Rust gains Mozilla's backing (InfoWorld)
Posted Nov 3, 2016 13:01 UTC (Thu) by kevincox (subscriber, #93938)In reply to: Project for porting C to Rust gains Mozilla's backing (InfoWorld) by valarauca
Parent article: Project for porting C to Rust gains Mozilla's backing (InfoWorld)
This is NOT how integer overflow works in C. In C unsigned integer overflow is undefined. In Rust "release" builds integer overflow is two's-compliment wrapping.
While in many cases the compiler will use the platforms native overflow behavior an optimizing compiler will often make assumptions because it doesn't have to wrap like the native platform.
For example (x + 1 < x) will be optimized to (0) by most compilers. You will also often see compilers promote small integers to machine words which will cause non-wrapping behavior when you are working with integers that will be used as memory offsets (including array indexes)
