A very strange case when it just happened to me - when using the debugger, it shows me that the value of some logical variable is true , but when I print it (or do any other operation with it), it behaves like 0 (i.e. false).
What can I do to fix this error? I'm afraid this is an environmental mistake, so publishing the sample code will be pointless. (a hidden, annoying memory management error cannot be the cause, right?), and in this context I want to note that it will surprise me when I find that my environment is poorly configured (I have been working on this project for more than a year now).
So far, I:
- It is checked twice that the compiler does not do any optimization for the code in my project properties.
- Tried to re-open the visual studio and clean and rebuild the project
- Search the Internet for solutions (not found). I am using visual studio 2010, and my programming language is C ++
Regarding code sharing requests:
Sorry, but I canโt post the code (my bosses will not be happy to see it running on the Internet). If you can give some ideas about the possible causes of the problem, it will be great, and I will look for the keys in the code myself to check if these causes caused this problem. However, to be clear, here are a few code lines that fight me:
bool dir = getNode(location)->getNext()->getDirection(); //dir is displayed as "true" in the debbuger int toPush = (dir == 1) ? 1 : 0; //"toPush" is displayed as "0" in the debbugger cout<<dir<<endl; //both output 0. cout<<(dir == true)<<endl;
Following your request, I am enclosing a screen shot. Pay attention to the value of "dir", which is deactivated on the right side of the screen as "true", and the output of the program on the right, which ends with 0 (which corresponds to the command "cout <dir").
screenshot
source share