Global Variables in Polyspace Bug Finder
When you run a Bug Finder™ analysis, Polyspace® makes certain assumptions about the initialization of global variables. These assumptions depend on how you declare and define global variables. For example, in this code
int foo(void) {
    return 1/gvar;
}gvar in these cases:
- You define - int gvar;in the source code and provide a- mainfunction that calls- foo. Bug Finder follows ANSI standards that state the variable is initialized to zero.
- You define - int gvar;or declare- extern int gvar;in the source code. Another function calls- fooand sets- gvar=0. Otherwise, when your source files are incomplete and do not contain a- mainfunction, Bug Finder makes no assumption about the initialization of- gvar.
- You declare - const int gvar;. Bug Finder assumes- gvaris initialized to zero due to the- constkeyword.
At the cost of a possibly longer runtime, you can perform a more
            exhaustive analysis where all values are considered for each read of a global variable
            by foo or of its callees when showing defects. See Extend Bug Finder Checkers to Find Defects from Specific System Input Values.
See Also
Inputs in Polyspace Bug Finder | Bug Finder Analysis Assumptions