-
Notifications
You must be signed in to change notification settings - Fork 277
prohibit pointers to bit-vectors that are not byte-aligned #7444
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
17ac3a6
to
52bb522
Compare
src/ansi-c/c_typecast.cpp
Outdated
if(width % config.ansi_c.char_width != 0) | ||
return std::string( | ||
"bitvector must have width that is a multiple of CHAR_BIT"); | ||
else |
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.
Nit pick: braces around multi-line body
src/ansi-c/c_typecast.cpp
Outdated
if( | ||
type.id() == ID_unsignedbv || type.id() == ID_signedbv || | ||
type.id() == ID_bv || type.id() == ID_floatbv) | ||
{ |
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.
Perhaps can_cast_type<bitvector_typet>
(which has several more cases that also seem legitimate).
src/ansi-c/c_typecheck_expr.cpp
Outdated
error().source_location = expr.source_location(); | ||
error() << *error_opt << eom; | ||
throw 0; |
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.
throw invalid_source_file_exceptiont{*error_opt, expr.source_location()};
src/ansi-c/c_typecheck_expr.cpp
Outdated
error().source_location = expr.source_location(); | ||
error() << "cannot take address of a single bit" << eom; | ||
error() << *error_opt << eom; | ||
throw 0; |
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.
throw invalid_source_file_exceptiont{*error_opt, expr.source_location()};
Codecov ReportBase: 78.41% // Head: 78.42% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #7444 +/- ##
===========================================
+ Coverage 78.41% 78.42% +0.01%
===========================================
Files 1659 1660 +1
Lines 190382 190371 -11
===========================================
+ Hits 149280 149304 +24
+ Misses 41102 41067 -35
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This adds checks to the C front-end that prohibit taking the address of objects that cannot be addressed with byte-granularity pointers. This includes proper Booleans (not to be confused with _Bool) and __CPROVER_bitvector-typed objects whose width is not a multiple of 8. Fixes #7104.
52bb522
to
0aba4e8
Compare
This adds checks to the C front-end that prohibit taking the address of objects that cannot be addressed with byte-granularity pointers. This includes proper Booleans (not to be confused with
_Bool
) and__CPROVER_bitvector
-typed objects whose width is not a multiple of 8.Fixes #7104.