Joe Buck <[EMAIL PROTECTED]> writes: | On Thu, Jun 30, 2005 at 09:02:48PM -0400, Andrew Pinski wrote: | > But the reason question is why make it an undefined behavior instead of | > an implementation defined? This would have made it clearer instead of | > allowing the compiler not document what happens. Or is C++ | > just following C here? In which case it might be better to ask the C | > committee why it was done this way and real definition of undefined for | > this case? | | I already showed you the answer: loop optimization works better if you | can ignore overflow.
There are various ways to work within "loop optimization" assumptions. Assuming undefined behaviour is not the only one. In fact, given the fact that the natural integer type for indices is "int" and not "unsigned" and the known dislike of the original implementer of C++ for "unsigned", it is legitimate to question whether that is "the answer". I think that can be an "a posteriori" justification, but I'm not sure that is "the answer". -- Gaby