This isn't complete example. I don't remember the details unfortunately.
But somehow compiler has decided that i <= limit is always true.