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
User interface (desktop products only): In your project configuration, the option is on the Check Behavior node.
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Static Analysis tab on the Run Time Errors > Check Behavior node.
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
- On
Polyspace 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
var2
in theif
branch. The verification continues as if only theelse
branch of theif
statement exists.A green Non-initialized local variable check on
var1
in the last statement.var1
has 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
var2
has full range ofint
values. Following theif
statement, because the software considers bothif
branches, it assumes thatvar1
also has full range ofint
values.Produces an orange Overflow check on the
+
operation. For instance, ifvar1
has the maximumint
value, 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
|