Skip to content

Compiler is unable to prove that bounds(p, p + len + 1 - 1) imply bounds(p, p + len) #1088

Closed
@kkjeer

Description

@kkjeer

Consider the following example:

void f(_Nt_array_ptr<int> p : count(i), unsigned int i) {
  if (*(p + i)) {
    ++i;
  }
}

At the beginning of the statement ++i, p has the widened bounds bounds(p, p + i + 1). The original value of i is i - 1. At the end of the statement ++i, p has the inferred bounds bounds(p, p + i - 1 + 1). The compiler currently emits a warning: "cannot prove inferred bounds for p imply declared bounds for p after increment". These bounds are in fact equivalent to bounds(p, p + i) if we perform constant folding, so the compiler should not emit a warning here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions