Skip to content

C++: Range analysis not picking up on condition because of implicit casts #3290

@criemen

Description

@criemen

Description of the issue

void test(unsigned long count) {
    for (int i = 0; i < count - 2; ++i) {
        sink(i);
    }
}

By looking at the code, we would expect a bound of the form i <= count -3 at the sink call.
However, because of the implicit conversion from int to unsigned long (which is not a safeCast),
the range analysis ignores the condition.

A case should be added to the RA that handles this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions