I declared a variable as static inside a function which is called periodically. I know that declaring a variable as static makes it live during the program lifetime without redeclaring it again. Of course, as it local, it should only been modified by its function.
The strange thing is that debugging the code, The function is executed and before leaving the function, I made sure that the value of the variable is 0
. In the next function call, the value of the variable is incremented by 256
before executing any line of the function. If the variable's value was 10
before leaving the function, it becomes 266
the next call. This behavior is persistent.
What can cause the local static variable's value to change between function calls?
Unfortunately I can't submit a code snippet that reproduces the problem.