-
Notifications
You must be signed in to change notification settings - Fork 274
Handle bool expressions in implicit_typecast_arithmetic #5758
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 #5758 +/- ##
=========================================
Coverage 76.73% 76.74%
=========================================
Files 1579 1579
Lines 182008 182164 +156
=========================================
+ Hits 139671 139795 +124
- Misses 42337 42369 +32
Continue to review full report at Codecov.
|
src/ansi-c/c_typecast.cpp
Outdated
@@ -619,8 +619,10 @@ void c_typecastt::implicit_typecast_arithmetic( | |||
if(max_type==LARGE_SIGNED_INT || max_type==LARGE_UNSIGNED_INT) | |||
{ | |||
// get the biggest width of both | |||
std::size_t width1 = to_bitvector_type(type1).get_width(); | |||
std::size_t width2 = to_bitvector_type(type2).get_width(); | |||
std::size_t width1 = |
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.
Would it make sense to use c_type1 and c_type2 instead of type1 and type2?
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.
Agreed; this should be post-promotion.
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.
But then we'd need new facilities to turn a c_typet
into a typet
. It's kind-of done by c_typecastt::implicit_typecast_arithmetic, but that doesn't do anything about a LARGE_SIGNED_INT
(or LARGE_UNSIGNED_INT
).
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've now implemented this without a need for to_bitvector_type
at all. Maybe I'm missing something? The new implementation seems almost too simple.
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 think @kroening 's suggestion is correct.
src/ansi-c/c_typecast.cpp
Outdated
@@ -619,8 +619,10 @@ void c_typecastt::implicit_typecast_arithmetic( | |||
if(max_type==LARGE_SIGNED_INT || max_type==LARGE_UNSIGNED_INT) | |||
{ | |||
// get the biggest width of both | |||
std::size_t width1 = to_bitvector_type(type1).get_width(); | |||
std::size_t width2 = to_bitvector_type(type2).get_width(); | |||
std::size_t width1 = |
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.
Agreed; this should be post-promotion.
We use Booleans instead of int as type of binary predicates, and enums don't convert to bitvector types directly either. This must not preclude mixing binary predicates with bitvector-typed expressions. Fixes: diffblue#5103
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.
Yeah, that does seem rather simple :-) but I can't at the moment see why it'd need to be more complex 🤷
We use Booleans instead of int as type of binary predicates. This must
not preclude mixing binary predicates with bitvector-typed expressions.
Fixes: #5103