It sounds like you are debugging an optimized build.
The debugger 'knows' the value of your local variables because the symbol file describes their location in the functions stack frame.
The debugger can then read the variables out of the memory of the target process. However, this requires that the stack frame contains up to date copies of the local variables. When compiling without optimizations the generated code will always write local variables back to their stack frame locations every time they are modified. This makes debugging easy, but costs at runtime.
For an optimized build the compiler will frequently deduce that these steps are unnecessary, and keep a value in a CPU register for as long as it is needed. It may well be that the local variable never gets a value written onto the stack at all. The debugger in this case has no way of tracking the value of the variable, but also doesn't know this and will often report data from the stack as if it were the variable value.