This small C++ program demonstrates an apparent optimization bug in g++.
It's based on a question on Stack Overflow: Does C++ allow an optimizing compiler to ignore side effects on the for-condition?. (I'm reasonably sure the answer in this case is no.)