-
Notifications
You must be signed in to change notification settings - Fork 80
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
Member expression bounds checking in multiple assignments #1181
Conversation
…set the observed bounds of A to its target bounds if it does not already have observed bounds recorded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
…into member-exprs-multiple-assignments
|
||
void multiple_assignments2(struct S *s) { | ||
// Observed bounds context after statement: { s->a => bounds(s->a - 1, (s->a - 1) + 2) } | ||
s->a = s->b, s->a++; // expected-warning {{cannot prove declared bounds for 's->a' are valid after increment}} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: at the assignment s->a++
, the observed bounds of the RHS s->a + 1
of the assignment should be bounds(s->b, s->b + 2)
, not bounds(s->a, s->a + 2)
. This can be done in a follow-up PR.
…y virtue of the fix in PR #1181.
* Parsing support for bundled statements. * Semantic actions to support bundled statements. * The bundled block functionality as per the Checked C specification. * Test cases in checkedc-clang repository for bundled block support. * Added more tests and fixed a minor issue. * Incorporated review comments. * Moved test case file to a more appropriate directory. * Incorporated a missed review comment. * Removed bounds checking error messages which are no longer expected by virtue of the fix in PR #1181.
This PR fixes an issue with bounds checking member expressions across multiple assignments.
Consider an example:
After the assignment
s->p = arr
, the observed bounds ofs->p
arebounds(arr, arr + 3)
. At the assignments->len = 3
, we synthesize the member expressions->p
whose target boundsbounds(s->p, s->p + s->len)
use the value ofs->len
. However, sinces->p
already has observed bounds recorded inState.ObservedBounds
, we do not update the observed bounds ofs->p
to its target bounds. Therefore, the assignment tos->len
does not modify the observed bounds ofs->p
. At the end of this statement, the observed bounds ofs->p
arebounds(arr, arr + 3)
and we have equality betweens->p
andarr
and betweens->len
and3
. The observed boundsbounds(arr, arr + 3)
imply the target boundsbounds(s->p, s->p + s->len)
. No errors or warnings are emitted.