Disable checks for non-initialization (-disable-initialization-checks)
Disable checks for non-initialized variables and pointers
Description
This option affects a Code Prover analysis only.
Specify that Polyspace® Code Prover™ must not check for non-initialization in your code.
Set Option
Set the option using one of these methods:
Polyspace user interface (desktop products only): In your project configuration, select the Check Behavior node and then select this option.
Polyspace Platform user interface (desktop products only): In your project configuration, on the Static Analysis tab, select the Run Time Errors > Check Behavior node and then select this option.
Command line and options file: Use the option
-disable-initialization-checks. See Command-Line Information.
Why Use This Option
Use this option if you do not want to detect instances of non-initialized variables.
Settings
OnPolyspace Code Prover does not perform the following checks:
Non-initialized local variable: Local variable is not initialized before being read.Non-initialized variable: Variable other than local variable is not initialized before being read.Non-initialized pointer: Pointer is not initialized before being read.Return value not initialized: C function does not return value when expected.
Polyspace assumes that, at declaration:
Variables have full-range of values allowed by their type.
Pointers can be
NULL-valued or point to a memory block at an unknown offset.
Off (default)Polyspace Code Prover checks for non-initialization in your code. The software displays red checks if, for instance, a variable is not initialized and orange checks if a variable is initialized only on some execution paths.
Tips
If you select this option, the software does not report most violations of MISRA C™:2004 rule 9.1, and
MISRA C:2012 Rule 9.1.If you select this option, the number and type of orange checks in your code can change.
For instance, the following table shows an additional orange check with the option enabled.
Checks for Non-initialization Enabled Checks for Non-initialization Disabled void func(int flag) { int var1,var2; if( flag==0) { var1=var2; } else { var1=0; } var2=var1 + 1; }In this example, the software produces:
A red Non-initialized local variable check on
var2in theifbranch. The verification continues as if only theelsebranch of theifstatement exists.A green Non-initialized local variable check on
var1in the last statement.var1has the assigned value 0.A green Overflow check on the
+operation.
void func(int flag) { int var1,var2; if( flag==0) { var1=var2; } else { var1=0; } var2=var1 + 1; }In this example, the software:
Does not produce Non-initialized local variable checks. At initialization, the software assumes that
var2has full range ofintvalues. Following theifstatement, because the software considers bothifbranches, it assumes thatvar1also has full range ofintvalues.Produces an orange Overflow check on the
+operation. For instance, ifvar1has the maximumintvalue, adding 1 to it can cause an overflow.
Command-Line Information
Parameter: -disable-initialization-checks |
| Default: Off |
Example (Code Prover): polyspace-code-prover
-sources |
Example (Code Prover
Server):
polyspace-code-prover-server -sources
|