-
Notifications
You must be signed in to change notification settings - Fork 86
Fix issues around Z3 sorts and floating-point flags. #1253
Fix issues around Z3 sorts and floating-point flags. #1253
Conversation
Fixes issues with integer binary operations with floating point numbers transmuted to integers. Fixes facebookexperimental#1252 (comment)
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1253 +/- ##
=====================================
- Coverage 74% 74% -1%
=====================================
Files 23 23
Lines 16795 16800 +5
=====================================
- Hits 12592 12587 -5
- Misses 4203 4213 +10 ☔ View full report in Codecov by Sentry. |
Expression::Transmute { operand, .. } => { | ||
self.get_as_numeric_z3_ast(&operand.expression) | ||
Expression::Transmute { operand, target_type } => { | ||
if target_type.is_integer() || target_type.is_floating_point_number() { |
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.
numeric_cast has logic for target_type == ExpressionType::Char, so it probably makes sense to use it for that case as well. I can imagine that transmuting a bit vector to a char might just happen somewhere, someday.
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.
Are you implying that simply dispatching to numeric_cast
would be enough in the case of Transmute
, without the conditional to fall back to get_as_numeric_z3_ast
? I can see that it will fall back to get_as_numeric_z3_ast
anyways. If you confirm, I will make a new commit.
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.
You'll still need the fall back. The idea would be to also use numeric_cast only in the case where target_type == ExpressionType::Char. I imagine that it might be interesting to write a test case for this.
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 if I add Char
type test like:
Expression::Transmute { operand, target_type } => {
if target_type.is_integer() || target_type.is_floating_point_number() || target_type == ExpressionType::Char {
self.numeric_cast(&operand.expression, *target_type)
} else {
self.get_as_numeric_z3_ast(&operand.expression)
}
}
it would be the same as
Expression::Transmute { operand, target_type } => self.numeric_cast(&operand.expression, *target_type),
because numeric_cast
basically falls back to calling get_as_numeric_z3_ast
internally.
Or perhaps I misunderstood your intent!
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.
Never mind then. I'll look into this separately when I get a chance.
Thanks for doing this! |
Description
get_as_numeric_z3_ast
meets theExpression::Transmute
case, by checking thetarget_type
and dispatching toget_as_numeric_z3_ast
.bv_overflows
.Fixes #1252.
Type of change
How Has This Been Tested?
Analyzing
libm
failed previously. Now it works.Checklist:
I have run
validate.sh
.main
.