What could be the cause of this if condition getting skipped even the condition inside is True?

168 views Asked by At

I am debugging a C++ project (A Plugin for Adobe InDesign) for a bug on OSX 10.9.5 using XCode 4.6.2. I have encountered very strange problem in the following code, the if statement in the following code is getting skipped even when the condition inside it is valid/true. When control reaches this if statement the value of insertSinglePageElement is 1, insertSinglePageElement is a bool16 variable. It must return true, still the code inside the if block is getting skipped.

Also, Does Xcode allows you to see the corresponding Assembly code? If yes then how?

bool16 insertSinglePageElement = kTrue;
...
//code
...
if(insertSinglePageElement == kTrue)
        {
            msgs = insertPageElementToPage(pe, pageData->grid, &pageName, pageData->presentationID, IDPageElementMap, true);

        } else {
            //Else Block

enter image description here

enter image description here

Above images show the value of variable and debugger showing the skipping of code in the second image by one step from the first one.

1

There are 1 answers

0
Abhishek On

The reason of this problem was that the TRUE block which XCode4.6.2 (Using Apple LLVM 4.2) showing to be true was not true. After turning Optimization on, X-Code started showing it as False.