Munair wrote:Actually I didn't look at the comments. Thanks for clearing that up. But the question is, should full optimization allow the iterator to go beyond array bounds (I know checking slows down)? I think every programmer has made that mistake once or twice. In any case, know what you do when going for full optimization. For example, Lazarus warns the programmer when setting optimization to -O4 (beware).
In this particular case, if the code
crashed, it would've very easy to track the error during
integration. As the faulty code was executed silently, the programmer had NO idea what went wrong. That's what I meant when I said that the code
didn't fail hard enough. Off-by-one errors are among the most common mistakes you can make, along with typos. One of the things that I hate the most when programming in C/C++ like languages, for example, is
case sensitiveness. This is especially outrageous when you work with code by others, or when porting it to another language (I port quite a lot of C++ code to FB).
Another example are divisions by zero. Your code can run perfectly fine with one or two per second, but not with a couple thousand (this is very easy to do, for example, when doing 3D or color manipulation). It's another of those very hard to track bugs that normally pass by silently at run-time, when in fact just a single little zero div should send your app crashing down to the floor engulfed in flames =D