Main Content

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:

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 EnabledChecks 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 the if branch. The verification continues as if only the else branch of the if 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 of int values. Following the if statement, because the software considers both if branches, it assumes that var1 also has full range of int values.

    • Produces an orange Overflow check on the + operation. For instance, if var1 has the maximum int 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 file_name -disable-initialization-checks
Example (Code Prover Server): polyspace-code-prover-server -sources file_name -disable-initialization-checks