QT debugger displaying incorrect value for variable (false instead of true)



  • I'm using QT Creator 3.5.1. I have QT 5.5.1 (MSVC 2013, 32 bit). Revision e548635a24. I also have Debugging Tools for Windows/CDB installed and auto detected by QT Creator.

    While debugging I encountered this situation:

    alt text

    Notice that isUdp is shown as being false, even though the current line arrow shows that we entered the true portion of the if statement.

    What's going on?



  • Hi, tooltips showing values in the code before the current breakpoint are not so trustworthy (maybe the compiler has optimized something for you). You could instead perhaps check by inserting a qDebug() << isUdp; between line 142 and 143,



  • Observed something similar myself once. The reason was that the compiler recognized that the variable (in your case isUdp), was set to true in every case and that it was not used anywhere else. So code was optimized in a way that the initialized value (false) was never overridden and it automatically jumped in the if-branch without checking the variable.

    If you have something similar and you print the value of isUdp before entering the if-branch to std:out, it should have the correct value (if the compiler doesn't optimize it in a way that it hardcodes the true-value at the output-command).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.