Static verification is an additional diagnostic capability to help you debug your programs. You can use the static verification options to detect potential errors in your compiled code including:
incorrect usage of OpenMP* directives
inconsistent object declarations in different program units
boundary violations
uninitialized memory
memory corruptions
memory leaks
incorrect usage of pointers and allocatable arrays
dead code and redundant executions
typographical errors or uninitialized variables
Static verification options can be used to analyze and find issues with source files; these source files need not form a whole program. (For instance, you can pass sources for libraries on the static verification command line.) In such cases, because only partial information is available about usage and modification of global objects, calls to routines, and so forth, analysis will be less exact.
Your code must successfully compile, with no errors, for static verification options to take effect.
The current usage model is that static verification is added as an alternate build option to produce a diagnostic report. When you enable static verification, the compiler will not create an executable file. Object files that are produced when using static verification are not valid and should not be used for generating real executable or static/dynamic link libraries.
Static verification cannot be used in conjunction with cross-file interprocedural optimization (/Qipo or -ipo).
Due to generalization of input data (static verification is performed for all possible input data), static verification cannot detect all possible errors that may appear during program execution.
Static verification uses a set of heuristics associated with the modification and usage of program objects. For example, when an undefined element of an array is set to some value, it is assumed that any arbitrary element of the array has been set to the same value. Similarly, after an undefined procedure call, it is assumed that all arguments substituted by reference are used and possibly modified.
Run-time checking executes a program with a fixed set of values for its input variables so it is difficult to check all edge effects. However, static verification performs a general overview check of a program for all possible values simultaneously.
Use the -diag-enable sv{[1|2|3]} (Linux* OS and Mac OS* X) or /Qdiag-enable:sv{[1|2|3]} (Windows* OS) compiler option to enable static verification. The number specifies the severity level of the diagnostics (1=all critical errors, 2=all errors, and 3=all errors and warnings).
Other related options include the following:
Option |
Result |
---|---|
-diag-disable sv Qdiag-disable:sv |
Disables static verification |
-diag-disable warn /Qdiag-disable:warn |
Suppresses all warnings, cautions and comments (issues errors only), including those specific to static verification |
-diag-disable num-list /Qdiag-disable:num-list |
Suppresses messages by number list, where num-list is either a single message or a list of message numbers separated by commas and enclosed in parentheses. |
-diag-file [file] /Qdiag-file[:file] |
Directs diagnostic results to file with .diag as the default extension. You need to enable static verification diagnostics before you can send them to a file. If a file name is not specified, the diagnostics are sent to name-of-the-first-source-file.diag. |
-diag-file-append[=file] /Qdiag-file-append[:file] |
Appends diagnostic results to file with .diag as the default extension. You need to enable static verification diagnostics before you can send the results to a file. If you do not specify a path, the current working directory will be searched. If the named file is not found, a new file with that name will be created. If a file name is not specified, the diagnostics are sent to name-of-the-first-source-file.diag. |
-diag-enable sv-include /Qdiag-enable:sv-include |
Diagnoses include files as well as source(s) |
If the -c (Linux OS and Mac OS X) or /c (Windows OS) compiler option is used on the command line along with a command line option to enable static verification, an object file is created; static verification diagnostics are not produced. This object file may be used in a further invocation of static verification. This feature is useful when a program consists of files written in different languages (C/C++ and Fortran).
To analyze OpenMP directives, add the -openmp (Linux OS and Mac OS X) or /Qopenmp (Windows OS) option to the command line.
When static verification support is enabled within the IDE, the customary final build target (e.g. an executable image) is not created. Therefore, create a separate "Static Verification" configuration.
In the Microsoft Visual Studio Environment, modify the existing Debug (development) configuration, as follows:
Select the Project Configuration Manager either from the Build menu or from the Project Properties window.
In the Active Solution Configuration dropdown, select <New..>
Provide a name for this configuration.
Specify to "Copy Settings from" the Debug configuration.
Exit the Configuration Manager.
With the new configuration active, navigate to the C/C++ > Diagnostics property page. Use the Level of Static Analysis and Analyze Include Files properties to control static verification.
In the Eclipse* IDE, do the following:
Open the property pages for the project and select C/C++ Build .
Click the Manage… button.
In the Manage dialog box, click the New… button to open the Create configuration dialog box.
Supply a name for the new configuration in the Name box
Supply a Description for the configuration if you want (optional).
You can choose to Copy settings from a Default configuration or an Existing configuration by clicking the appropriate radio button and then selecting a configuration from the corresponding drop down menu.
Click OK to close the Create configuration dialog box.
Click OK to close the Manage dialog box (with your new configuration name selected).
The property pages will now display the settings for your new configuration; this becomes the active build configuration. Navigate to the Intel compiler's Compilation Diagnostics properties. Use the Level of Static Analysis and Analyze Include Files properties to control Static verification.
In the Xcode* IDE, modify the existing debug (development) configuration, as follows:
Double click the Target to Get Info
Navigate to the Build properties page.
Expand the Configuration drop down and select Edit Configurations...
Select the Debug configuration.
Click the Duplicate button at the bottom of the page.
Optionally change the configuration name; the default name is Debug copy.
Exit the page.
With the Configuration set to the new configuration, navigate to the Intel compiler's DIAGNOSTIC collection of properties. Use the Level of Static Analysis and Analyze Include Files properties to control static verification.
Set the Active Target and Active Build Configuration appropriately to BUILD the static verification enabled configuration.
Static verification capabilities include the following: