|
|
|
|
|
by steveklabnik
25 days ago
|
|
> You can tune a C compiler as well to have a very specific defined behaviour for integer overflow. You can add -fwrapv or you can add UBSAN. This is an example of a compiler flag that adds definition to undefined behavior, which is of course, legal to do. That doesn't change that in the standard, it is undefined behavior, and in Rust, it is not. > To say that overflow would be defined in Rust is at least half a lie. In the context of "undefined behavior", it is not a lie at all. > So the user has to constrain the set of valid inputs, and do manual sanitization, just like in C. No, because the consequences of how the two languages define these behaviors are very, very different. |
|
Just saying that it's defined and then not saying what the definition is, is no different from saying it's undefined.