-
Notifications
You must be signed in to change notification settings - Fork 284
Relational operators support for pointers in new SMT backend #6905
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
Relational operators support for pointers in new SMT backend #6905
Conversation
| { | ||
| int *x; | ||
| int *y; | ||
| __CPROVER_assume(x > y); |
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.
Please revise these tests -- relations on nondeterministic pointers have no meaning. You need to make those pointers point to the same object.
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.
Hi Daniel, do the changes in 36e0955 look like an acceptable fix to this?
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.
Yes, that's fine. It may confuse one or the other reader that you are using x both as a source of nondeterminism and as "target" for the pointers.
Codecov Report
@@ Coverage Diff @@
## develop #6905 +/- ##
===========================================
- Coverage 77.81% 77.79% -0.03%
===========================================
Files 1568 1568
Lines 179985 180301 +316
===========================================
+ Hits 140054 140262 +208
- Misses 39931 40039 +108
Continue to review full report at Codecov.
|
8524840 to
36e0955
Compare
| @@ -0,0 +1,13 @@ | |||
| CORE | |||
| pointers_stack_malloc.c | |||
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.
⛏️ Isn't stack_malloc a contradiction, given than malloc allocates heap memory, not stack memory?
|
|
||
| int main() | ||
| { | ||
| int *a = malloc(sizeof(int) * 5); |
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.
ℹ️ This test is pretty close to running into the unimplemented array functionality. Adding --no-array-field-sensitivity to cbmc will cause a failure. Also replacing the last for loop using a non-det range for the i variable will do the same -
#include <stdlib.h>
int main()
{
int *a = malloc(sizeof(int) * 5);
for(int i = 0; i < 5; i++)
*(a + i) = i;
int i;
__CPROVER_assume(i >= 0);
__CPROVER_assume(i < 5);
{
__CPROVER_assert(*(a + i) >= i, "*(a + i) >= i: expected successful");
__CPROVER_assert(*(a + i) <= i, "*(a + i) <= i: expected successful");
__CPROVER_assert(*(a + i) == i, "*(a + i) <= i: expected successful");
__CPROVER_assert(*(a + i) != i, "*(a + i) <= i: expected failure");
}
}
No need to action this comment. I just wanted to make note of my findings into why this array using example works despite the unimplemented array functionality.
36e0955 to
f633c5b
Compare
f633c5b to
118b5b1
Compare
This PR is adding support for relational operators as applied
to pointers in the new SMT backend.