3 ms·
It is less of a "problem" with the standard, but more of a "design decision". Performance is more important to C-people. For example, the result of x+y is unde
by qznc 14y ago
It is less of a "problem" with the standard, but more of a "design decision". Performance is more important to C-people.
For example, the result of x+y is undefined for signed integers in C, because we want it to compile it to a minimum number of instructions on every architecture. No instructions to check for overflow and branching afterwards. No error correction instructions on architectures where semantics differ to the language semantics.
- bcoates 14y agoYou're exaggerating a little, x+y is defined over signed ints as long as as it doesn't over/underflow. If it does overflow, it's either a target-specific hand optimization or a programmer error, but that varies on a program-by-program basis, hence GCC having -fwrapv, -ftrapv, and the default of "I don't do that, optimize accordingly".