LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler Bug: (0x228360 == 0) was TRUE!!

A compiler (or debugger) bug has been found.  Please see the attached screenshot of a watch window.  In the window, there is a variable Tasr_Vi.  It has a value of 0x228360.  This variable was compared against 0 in an if statement, and the comparison returned true!
 
if (Tasr_Vi == 0)    // Tasr_Vi currently has a value of 0x228360
{
/* BUG: We got here!! */
}
This is clearly either a compiler bug, or a debugger bug, or a combination of both of them.  It is not possible that there is no compiler bug and no debugger bug.  Zero is only equal to 0x228360 for very large values of zero.
 
We can make code available to NI so that you can duplicate this bug, and fix it.  When can you have the bug fixed?
 
Thank You,
Ken Hendrickson
Harris Corp.
 
 
0 Kudos
Message 1 of 6
(3,391 Views)

Ken,

First off, I would be more than happy to look at your code and work on figuring out what is going on.

However, based on looking at your attached screenshot, there is something else I think we can try first. The watch on the Tasr_Vi variable is local to SR192_Proj.c, while the other watch expressions are local to uutcsc02.c. Depending on how this variable is scoped, this could explain the difference in the values (which could be correct). This could be caused by Tasr_Vi being a static global variable defined in both files, etc. Try changing the file context for Tasr_Vi to be in uutcsc02.c and see if it then shows the value as being zero (this would be my guess). If this is not the case, let me know and we can look into this further.

Thanks,

-alex

0 Kudos
Message 2 of 6
(3,368 Views)
It is a static global variable.
It is exactly the same variable.
 
Ken
 
 
0 Kudos
Message 3 of 6
(3,360 Views)
Ken,
 
A static global is only visible within one compilation unit (file). If it is really static then there is no way it can be the same variable since the file contexts are different (unless you include one .c file in another).
 
-alex
Message 4 of 6
(3,358 Views)
I feel so embarrassed.  🙂  Thanks!
 
You are absolutely right.  They are different variables, because they were static globals in different files.
 
So there is no compiler bug!
 
Thank you very much!
 
Ken
 
 
0 Kudos
Message 5 of 6
(3,352 Views)

You can solve it as well when you define one of the two as an extern.

With #ifdef you could switch back and forth between extern and static whenever a module was used by itself.

Zero can have quite a large actual value if it is used in a political or military context, btw... but that's another forum 🙂

0 Kudos
Message 6 of 6
(3,325 Views)