MSVC2010 Possible Bug?

Started by
5 comments, last by Trienco 11 years, 11 months ago
My program is coded in C++. It's a pretty general question so I should not need code to give an example. Basically I have member values that come up as invalid in the bottom box during debug mode. I checked these values by calling some functions that would return them and the exact same values the debug mode says is invalid comes back with valid values. I made sure I did the value checks at the exact same point in the program that the debugger shows them as invalid. In case it helps and is part of the cause these values are created after manipulating values read from a file in binary format with ifstream. I'll reiterate, these values are for sure valid because their return values are valid, but the debugger is saying they aren't. Is it a bug or is it possible I am still doing something wrong?
Advertisement
I know from experience that the MSVC debugger can very easily get confused when debugging optimized code. It doesn't understand what's going on when variables get optimized into registers for example.

Normally in debug mode with optimizations off it does tell you the correct answer, but it's possible there's a bug. The best way to verify that the program is working correctly is to either examine the disassembly, or add some extra debug output.

It's hard to be more specific without being able to reproduce it. A small example program that demonstrates the problem would be handy.
It appears this bug just appeared today after having added a new member to the class showing the invalid values in the debugger. A simple int and two functions setting the int and returning the int. For some reason adding this caused the debugger to go nuts showing other members in the class as having outrageous values even though they do not. The values that are shown as invalid are however read from a file during run time and the new member I added is not, but only because it is needed after the load of this class. It shouldn't have any effect on the other members since I didn't add it to my save and load functions. I guess I am just going to move on though and let this go.

Update: I went ahead and added the member to the save and load functions and saved a new instance of the class for loading/testing. The problem is still there but it is worth noting the new member does not at all appear in the debugger under the list of class members. This all seemed to familiar and it was because I had remembered this happening before and that the problem had eventually disappeared on its own. I am not going to worry about it any longer.
Be careful that you aren't violating the One Definition Rule somewhere. That really confuses the debugger, even in debug :)
I don't know if it goes without saying, but did you try a clean/rebuild of your project? It may affect what you see, versus what the debugger thinks is true, if you edit a header and it does not recompile correctly. If it is working, then great, but if you didn't do a rebuild, that may have fixed it. Not saying you forgot, but there was no mention, and can't hurt to cover the bases in case it happens again :)

I don't know if it goes without saying, but did you try a clean/rebuild of your project? It may affect what you see, versus what the debugger thinks is true, if you edit a header and it does not recompile correctly. If it is working, then great, but if you didn't do a rebuild, that may have fixed it. Not saying you forgot, but there was no mention, and can't hurt to cover the bases in case it happens again smile.png


You were right to ask. No I didn't rebuild, building always seemed sufficient. However rebuilding did make the problem go away. Thank you. + rep for you biggrin.png
One important rule:

If you make last minute changes while compiling, save the file and are told "I'm kind of busy compiling, save anyway?" you should be aware of the consequences of saying "Yes". Essentially it means that the next time you compile, it will likely NOT rebuild the file, because based on the time stamp it thinks it already did compile the latest version.
f@dzhttp://festini.device-zero.de

This topic is closed to new replies.

Advertisement