I really love the "Send us the code, before and after" "explain what you expect".
I do the same. Hey, I even demand the same. (Years ago I was head of support/QA in a company, the official bug report forms I designed had fields for this, with great success) I thought I was above such details this time. <beep> Wrong!
There is this great saying, that I use with friends/colleagues, when we hit an "impossible" problem/bug/behaviour in the systems we work with:
"Explain it to the teddy bear"
Usually, when explaining a problem in excruiating detail to the teddy bear (or a colleague
) you suddenly see the problem from a new angle or discover a presumption you made that was never made explicitly clear.
And thus the error is discovereed, the problem solved. Humbly I realized my hidden assumption in this case, too.
So - the example in this thread will work.
My code (see the link) left the calling function (loop) and in again and the called function assumed(!) that the parameter it had gotten was unchanged by the caller. Which it wasn't as it is un-static.
I conclude it is very bad coding style for a function to assume that it can use the by reference parameters as (static) storage, between invokations of being called. Too aggressive in saving precious memory bytes. My excuse is that the function was always inline with global variable. As the linked thread says - I converted it to library, and this is where all probelms began. Before the variables were global but you cant do that with a library. I'll fix the code, and "waste" 3 bytes.
Thank you for reading. Now move along, there is nothing more to see here.