-
Notifications
You must be signed in to change notification settings - Fork 277
Limit dereferencing of __CPROVER_bitvector
to objects with size multiple of 8
#7298
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
Hi @tautschnig, this PR is now making bit vector dereferences that are not size-multiple of 8 fail type checking. This had the side-effect of causing some tests you added recently to fail, for instance: __CPROVER_bitvector[1] *bptr = &A[len - 1];
*bptr = 0; This construct in Is this the way to go, or should we be doing things a different way? If yes, shall we delete the tests (given that they appear to have been invalidated by this change). |
src/ansi-c/c_typecheck_expr.cpp
Outdated
|
||
if(is_signed_or_unsigned_bitvector(expr.type())) | ||
{ | ||
auto bv_type_width = to_bitvector_type(expr.type()).get_width(); | ||
if(bv_type_width % 8 != 0) | ||
{ | ||
throw invalid_source_file_exceptiont{ | ||
"only bitvectors of size multiple of 8 can be dereferenced", | ||
expr.source_location()}; | ||
} | ||
} |
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.
I'm not sure the C front-end is a sufficiently general layer for this check: we might need to do it during goto-program conversion, or perhaps even later (maybe even the back-end)? I don't think it's a C-specific issue at all.
Knowing that this is a non-trivial request: I don't think this test should be removed without replacement. It's right that this shouldn't be done via the C front-end, and not be done via pointers. What this test is supposed to exercise, however, could safely be exercised via the (existing, to-be extended) unit test of byte-operator lowering. So the gist of this regression test (which can most easily be found by running this test through |
f891e77
to
112151a
Compare
112151a
to
7777ccd
Compare
The problem this PR is supposed to fix was fixed in #7444. This is now no longer relevant as a PR, so closing it now. |
This should be resolving the first issue reported in #7104 by limiting the derefencing/taking of address of bit vector objects whose size is less than 8.
This is for now a draft, as I continue to QA the changes in this PR.
This is a partial solution to the problem described in #7104. There's going to be another PR with the solution to the second issue described there.