Skip to content

False Negative: INFINITE_EXECUTION_TIME missing for empty-increment for loop #2005

@leemeii

Description

@leemeii

Description
Infer fails to report an INFINITE_EXECUTION_TIME error when a for loop has an empty increment expression and the loop variable is never modified, resulting in an obvious infinite loop.

public class TestInfiniteLoop {
    static void bugMissed() {
        int j;
        for (j = 0; j <= 1;) {}  // <- should report INFINITE_EXECUTION_TIME (FN)
    }
}

Expected behavior
INFINITE_EXECUTION_TIME should be reported for void TestInfiniteLoop.bugMissed(), since the function contains a non-terminating loop whose execution cost is ∞.

Actual behavior
The infinite loop is silently ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions