Pointer overflow checks should detect overflow in offset multiplication#6633
Conversation
5980b0e to
81276c2
Compare
5204303 to
2a0230e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6633 +/- ##
========================================
Coverage 76.72% 76.72%
========================================
Files 1579 1579
Lines 181938 181953 +15
========================================
+ Hits 139587 139602 +15
Misses 42351 42351
Continue to review full report at Codecov.
|
35d46f3 to
6d9219d
Compare
src/analyses/goto_check_c.cpp
Outdated
| /// | ||
| /// A flag's initial value (before any `set_flag` or `disable_flag`) is restored | ||
| /// when the entire object goes out of scope. | ||
| class flag_resett |
There was a problem hiding this comment.
I realise this is just code you've moved, but just wondering about the naming of this class (sorry...) Conceptually what this class is really about is less about "resetting" a flag, and more about introducing a "scope" for the flag? So maybe call it something like flag_scopet ? or flag_overridet ? One for a later PR though.
There was a problem hiding this comment.
Good call, I think flag_overridet is the best match for what it does. I've inserted a commit to do the renaming.
No changes in behaviour, just code motion. Upcoming commits will use this class in `check_rec`.
There isn't any use of fields other than the instruction's source location, so take just that. Also use `as_string()` instead of `pretty()` for more nicely formatted error reporting.
This class no longer is confined to resetting flags, but now has additional override capabilities. Co-authored-by: Chris Ryder <chris.ryder@diffblue.com>
Pointer arithmetic requires multiplication of the offset by the size of the base type (for any base type larger than 1 byte). Such a multiplication isn't introduced until the back-end, where no opportunity for adding properties exists anymore. Therefore, synthesize the multiplication to generate arithmetic overflow checks at the GOTO level. Fixes: diffblue#6631
6d9219d to
419837e
Compare
chris-ryder
left a comment
There was a problem hiding this comment.
Re-asserting my approval after the extra rename commit, thanks :-)
Pointer arithmetic requires multiplication of the offset by the size of
the base type (for any base type larger than 1 byte). Such a
multiplication isn't introduced until the back-end, where no opportunity
for adding properties exists anymore. Therefore, synthesize the
multiplication to generate arithmetic overflow checks at the GOTO level.
Fixes: #6631