Skip to content

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

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

tautschnig
Copy link
Collaborator

We use Booleans instead of int as type of binary predicates. This must
not preclude mixing binary predicates with bitvector-typed expressions.

Fixes: #5103

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Jan 17, 2021

Codecov Report

Merging #5758 (ba41717) into develop (4c2c27d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head ba41717 differs from pull request most recent head 59a3c2a. Consider uploading reports for the commit 59a3c2a to get more accurate results

Impacted file tree graph

@@            Coverage Diff            @@
##           develop    #5758    +/-   ##
=========================================
  Coverage    76.73%   76.74%            
=========================================
  Files         1579     1579            
  Lines       182008   182164   +156     
=========================================
+ Hits        139671   139795   +124     
- Misses       42337    42369    +32     
Impacted Files Coverage Δ
src/ansi-c/c_typecast.cpp 81.19% <100.00%> (-0.19%) ⬇️
src/solvers/flattening/boolbv_add_sub.cpp 48.33% <0.00%> (-3.06%) ⬇️
src/ansi-c/expr2c.cpp 65.94% <0.00%> (ø)
src/ansi-c/c_typecheck_base.h 100.00% <0.00%> (ø)
src/solvers/flattening/boolbv.h 62.50% <0.00%> (ø)
src/solvers/flattening/bv_utils.h 85.71% <0.00%> (ø)
src/ansi-c/c_typecheck_expr.cpp 76.59% <0.00%> (+0.09%) ⬆️
src/solvers/flattening/boolbv.cpp 80.61% <0.00%> (+0.10%) ⬆️
src/goto-programs/remove_vector.cpp 97.00% <0.00%> (+0.31%) ⬆️
src/util/bitvector_expr.h 93.47% <0.00%> (+0.47%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c99dcc8...59a3c2a. Read the comment docs.

@@ -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 =
Copy link
Member

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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).

Copy link
Collaborator Author

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.

Copy link
Collaborator

@martin-cs martin-cs left a 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.

@@ -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 =
Copy link
Collaborator

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
Copy link

@chris-ryder chris-ryder left a 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 🤷

@tautschnig tautschnig merged commit 9cead93 into diffblue:develop Feb 26, 2022
@tautschnig tautschnig deleted the bool branch February 26, 2022 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

goto-cc crashes on softfloat code using __int128
4 participants