-
Notifications
You must be signed in to change notification settings - Fork 274
Simplification of nested pointer arithmetic: do not assume same type #6541
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
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #6541 +/- ##
========================================
Coverage 76.73% 76.73%
========================================
Files 1579 1579
Lines 181999 182005 +6
========================================
+ Hits 139652 139658 +6
Misses 42347 42347
Continue to review full report at Codecov.
|
2493497
to
ce7c83c
Compare
Does it make sense to tighten the typing rules for pointer arithmetic, and then to change the front-end? |
ce7c83c
to
97a22c6
Compare
I have now extended an existing test: the C front-end already does ensure consistent typing, so I don't think we have an issue in the front-end to resolve. No other place, however, is strict about the types in pointer arithmetic. Perhaps we should be? I don't know. |
I'd be in favour of tightening the typing; this makes every bit of code that 'reads' a lot easier. There will be more of that than code that 'writes', and that would not get much more difficult. |
Use temporaries to ensure const-access where possible and name subexpressions. This helps navigate the various uses of opX() in this code. No change in behaviour is expected. This code is covered by at least 33 of the regression/cbmc/ tests as well as several other regression tests.
Pointer arithmetic is permitted with both signed and unsigned numeric operands. Nested expressions could possibly mix this when the front-end does not strictly use the same type for pointer arithmetic as for index types. Observed in model-checking/kani#708. Introducing type casts (as needed) exposed a further issue in this code: it previously did not make sure that it was really the numeric operands that ended up being grouped together. This became apparent on test Pointer_Arithmetic15, which specifically constructs such expressions.
97a22c6
to
b4c2ff1
Compare
@kroening As now being discussed in #6731 making changes in Kani could well be the way to go. That said, however, this PR also fixes other issues in the offending simplifier code as indicated in the commit message, so perhaps merging these changes is a right first step? |
Please review commit-by-commit: the first commit is a refactoring only.