First, a simple error. For benchmarks, you always want to turn all compiler optimisations on, otherwise you're testing something different from the real thing. However, the problem is when you isolate an algorithm in a simple looping test like this one. If your algorithm does something really simple and with few side effects, the compiler could simplify parts of your algorithm awaysimplify parts of your algorithm away!
Some more relevant information: http://stackoverflow.com/q/8547778/2038264https://stackoverflow.com/q/8547778/2038264