4 ms·
The original intent was for signed overflow to be architecture-specific (not everything was 2s complement back then). On x86, the correct behavior was previous
by hedora 6y ago
The original intent was for signed overflow to be architecture-specific (not everything was 2s complement back then).
On x86, the correct behavior was previously (and obviously) “perform a 2s complement wraparound”.
To “ignore” the situation used to mean “delegate to a lower level”. It now means “silently generate code that violates the semantics of the target microarchitecture”
As the article argues, I think this has gone too far. For example, people are starting to claim that asm blocks are undefined behavior. They’re clearly implementation specific (so undefined by the spec), but also well defined by each implementation.
In current readings of the spec, compilers are free to ignore them completely. Doing so would break all known operating systems, and many user space programs, so they have not managed to do so yet.
Edit: for signed overflow, other architecture-specific behavior (such as optionally trapping floating point exceptions) would also have been permissible, assuming the architecture supported it.
- jcranmer 6y ago> The original intent was for signed overflow to be architecture-specific (not everything was 2s complement back then). The term for that is implementation-defined, not undefined. If it were to be architecture-specific, back in C89, they would have used the term implementation-defined, as they do for things like the size of pointers.
- anarazel 6y agoThere's "implementation defined" for the concept you describe.