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:
Static verification options can be used to analyze both completed applications as well as those in currently being developed.
When you invoke the compiler option to enable static verification, the compiler will not produce an executable file and, therefore, 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 rather hard 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* and Mac OS*) or /Qdiag-enable:sv{[1|2|3]} (Windows*) compiler option to enable static verification. The number specifies that the severity level of the daignostics (1=all critical errors, 2=all errors, and 3=all errors and warnings).
The command line can contain multiple source files; object files are created for each source file. All object files are processed simultaneously.
Other related options include the following:
-diag-disable sv |
Disables static verification |
-diag-disable warn |
Suppresses all warnings, cautions and comments (issues errors only), including those specific to static verification |
-diag-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} |
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-enable sv-include |
Diagnoses include files as well as source(s) |
If the /c 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 and Mac OS) or /Qopenmp (Windows) option to the command line.
You can use static verification options on mixed-language applications that make use of both C/C++ and Fortran code. Object files will be created from the C/C++ and Fortran sources.
Additionally, static verification can be used on object files created for IPO.
Static verification capabilities include the following:
The following topics describe these capabilities in more detail.