Skip to content

Conversation

@kkjeer
Copy link
Contributor

@kkjeer kkjeer commented Aug 24, 2021

Fixes #1158

This PR updates the bounds checking behavior for lvalue expressions with bounds-safe interfaces in unchecked scopes.

If:

  1. A statement S is in an unchecked scope, and:
  2. An lvalue expression e has unchecked pointer type (its bounds were declared using a bounds-safe interface), and:
  3. S does not contain an assignment e = e1 where e1 is a checked pointer, then:

The bounds of e are not validated after checking S.

kakje added 10 commits August 23, 2021 15:14
LValuesAssignedChecked contains AbstractSets representing lvalues expressions that have unchecked pointer type that were assigned a checked pointer during the current top-level statement (if the statement is in an unchecked scope). AbstractSets in LValuesAssignedChecked should have their bounds validated after checking the current statement.
Copy link
Contributor

@sulekhark sulekhark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (there's just one minor comment)! Thank you!

p += i;

// The type of the RHS expression p + r is int *, so a checked pointer is not
// assigned to p here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the code that the comment on lines 841 and 842 is referring to is missing (not sure).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on lines 841 and 842 is referring to the code on line 843, since the type of the RHS expression p - (_Array_ptr<int>)q is int *.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has a typo, so I'll update the comment - thanks for catching this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not emit bounds checking warnings or errors for bounds-safe interfaces in certain contexts

3 participants