Vincent Lefevre wrote:
No, this isn't what I meant. The C standard doesn't assume wrapping, so I don't either. If the compiler doesn't either, then it can do some optimizations. Let's take a very simple example:
We perfectly understand that if the compiler does not assume wrapping, but instead assumes that integer overflow is undefined, then some possible optimization opportunities open up (how could anyone reading this thread not understand this, far better examples have been given than the one you give here). No one is contesting that, or failing to understand that this is of course true. So we don't need another simple-minded tutorial on that issue! The issues are a) are these optimizations valuable? (and if so, in all cases, or only in practice for loop invariants?). b) are these optimiztions judicious? they are allowed by the standard, but then a lot of things are allowed by the standard that we do not take advantage of (such as fast math), but do they cause too many surprises given actual C coding practices. And it is on these two points that people (rather strenuously) disagree.