Skip to content

Invertibility for unchecked pointers #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 20, 2021
Merged

Conversation

kkjeer
Copy link
Contributor

@kkjeer kkjeer commented Jul 13, 2021

Fixes #1123

This PR allows pointer arithmetic expressions with unchecked pointer type to be invertible. This means that unchecked pointers with bounds-safe interfaces in unchecked scopes can have inverses.

For example:

void f(int *p : count(1)) _Unchecked {
  p = p + 1;
}

In the body of f, p has the unchecked pointer type int * since it is in an unchecked scope. Before this PR, p would have no inverse in the expression p + 1. After this PR, p has the inverse p - 1.

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! Thank you! There's just one minor typo.

// Original value of i in i - 1: x
// Updated EquivExprs: { { x - 1, i } }, Updated SameValue: { i + 1 }
// Original value of i in i - 1: i + 1
// Updated EquivExprs: { { i + 1, i } }, Updated SameValue: { i + 1 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is a typo here: the updated equivalent expressions must be {i+1, x}.

Copy link

@mgrang mgrang left a comment

Choose a reason for hiding this comment

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

LGTM.

@kkjeer kkjeer merged commit 0ddc83c into master Jul 20, 2021
@kkjeer kkjeer deleted the invertibility-unchecked-pointers branch September 9, 2021 21:19
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.

Allow invertibility for unchecked pointers
3 participants