Saturday I posted a question about problems I was having with VC++ 2005 Express debugger. The thread I started has disappeared but the debugger problems have not. So I'm re-posting.
The debugger is intermittantly showing wrong values for variables and faining to single step correctly through code. For example:
in main:
bool x = true;
someFunc(x);
void someFunc(bool x)
{
if(x)
do A
do B, etc.
Inside someFunc, the debugger shows the value of x to be false. But
then if you single step, it executes do A, etc. as if x is true (which it is, or should be).
When this happens other values are also reported incorrectly. For example a filename buffer shows the right address for the buffer, but shows the wrong contents.
Variables that are created within the function I'm tracing are never shown to exist at all. Several lines of code--not within any conditional--are skipped over even when using step into. And yet, those lines apparently have been executed because the overall program behaves as if they have.
I have been able to find very little on this problem. (Believe me, I've looked!!)
I found one post on the C# forum describing the same problem:
QUOTE:
when stepping through code in a class that I wrote the debugger shows wrong values. Values of booleans, strings, and complex objects are often reported as nothing when they exist, false when they are true, etc. The code executes correctly but the values are reported wrong.
UNQUOTE
But they didn't post any answer there. The moderator there asked for the code by email but no one ever posted any resolution.
This is a real problem for me and I haven't a clue what could be wrong or how to fix it. Please could some knowledgeable person at least make a suggestion Thanks in advance.
Ron

Repost on problem with debugger reporting wrong values
kamila
Your post hasn't disappeared. It was simply moved to another forum--the Visual Studio Debugger forum. To track the status of your posts, please click on "My threads" at the top.
Please follow your question at the Debugger forum.
<rant>I agree, that these forums should make it more clear that a thread has been moved, since too many posters are taken by surprise.</rant>
Kang
liujj_xujj
You may be running into consequences of code optimization, although that should not apply to strings and other non-trivial stored values.
Also, your breakpoints may not be at the point you expect. They usually have the program stop before the statement on which the breakpoint is placed (with allowance for the optimizer possibly having moved some code around).
There are some things you can do:
1. Turn off optimizations and see if that makes any difference.
2. Look at the assembly language code. You can specify production of an assembly listing for any module by right-clicking on the file name in the Solution explorer, selecting Properties, and then specifying a file for assembly output in the Configuration Properties | C/C++ | Output Files pane.
3. You can also look at the code when the debugger has stopped at a breakpoint. Right click on the source program where the breakpoint has been hit and select "Go to Disassembly." It will show up in a tabbed window and you can look at more information.
4. Assuming that your program is not working properly, engage in traditional debugging by placing assertion statements and output statements that confirm the values available at various points in the code. You may want to break the program into chunks that are separately demonstrated to be working, and so on.
That's all I can offer off the top of my head.
- orcmid
moondaddy