I invented the missing parts (like the BufConfig struct) and stepped once through your code and it looks ok to me. i was incrementing properly.
The only reason I could imagine your behavior is if the debugger is not able to read the stack, but then it would not behave properly. Can you check if the location the debugger shows for the i variable is the one the code is using?
Also note that your code below does not have any effect at all. GainToIndice is missing a return, and also no global is ever written.
Daniel
PS: I take "However the result is true." as it steps through the code as you expect it too. There is no result or side effect in that code to observe.