4 ms·
> It didn't assume in that case either. It did a well defined thing: add checks. It did. The compiler added the checks (which panic on overflow, from a quick w
by jstimpfle 5mo ago
> It didn't assume in that case either. It did a well defined thing: add checks.
It did. The compiler added the checks (which panic on overflow, from a quick web search) precisely so it (and importantly, the developer!) can assume the overflow didn't happen in the subsequent code. Unless you consider a panic a defined state, and consider wrap-on-overflow equally valid in all cases, it's essentially the same as UB. (panic seems to be considered "unrecoverable").
Difference is _at most_ that C spec gives compiler more freedom to "implement UB", but then again, hit any unsafe code in Rust with wrapped around integer, you probably have comparable practical result -- machine doing random things, corrupting memory and so on.
- steveklabnik 5mo agoOkay, I am going to leave this here, as it’s clear to me that we’re not coming to an understanding.