Skip to content

Handle empty unions via dedicated expression #6408

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
Oct 21, 2021

Conversation

tautschnig
Copy link
Collaborator

GCC and Clang support empty unions, which the C standard does not
permit. We previously handled this special case by generating nil. This,
however, is not supported by the bitvector back-end. Rather than coming
up with selective handling of the otherwise unexpected nil, a proper
expression is introduced (and handled).

Fixes: #6163

  • Each commit message has a non-empty body, explaining why the change was made.
  • 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.

@tautschnig
Copy link
Collaborator Author

I should also revisit #5667 once this is merged.

class empty_union_exprt : public nullary_exprt
{
public:
empty_union_exprt(typet _type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make that constructor explicit.

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.

Yes. I'm probably being unhelpful but what happens if you have a pointer to one of these?

@tautschnig
Copy link
Collaborator Author

Yes. I'm probably being unhelpful but what happens if you have a pointer to one of these?

I don't think that would be a problem, as long as you never try to access any bytes in there.

@tautschnig tautschnig force-pushed the empty-union branch 2 times, most recently from 243bf48 to 79b7014 Compare October 21, 2021 19:06
GCC and Clang support empty unions, which the C standard does not
permit. We previously handled this special case by generating nil. This,
however, is not supported by the bitvector back-end. Rather than coming
up with selective handling of the otherwise unexpected nil, a proper
expression is introduced (and handled).

Fixes: diffblue#6163
@codecov
Copy link

codecov bot commented Oct 21, 2021

Codecov Report

Merging #6408 (eff2507) into develop (cab7f30) will decrease coverage by 0.00%.
The diff coverage is 95.27%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6408      +/-   ##
===========================================
- Coverage    75.98%   75.98%   -0.01%     
===========================================
  Files         1523     1524       +1     
  Lines       164284   164290       +6     
===========================================
+ Hits        124839   124843       +4     
- Misses       39445    39447       +2     
Impacted Files Coverage Δ
src/ansi-c/c_typecheck_base.h 100.00% <ø> (ø)
src/goto-programs/goto_convert_class.h 87.30% <ø> (ø)
src/jsil/jsil_parse_tree.cpp 0.00% <0.00%> (ø)
src/jsil/jsil_typecheck.cpp 0.00% <0.00%> (ø)
src/jsil/jsil_typecheck.h 0.00% <ø> (ø)
src/solvers/flattening/boolbv.h 76.19% <ø> (ø)
unit/goto-programs/goto_program_validate.cpp 100.00% <ø> (ø)
src/solvers/smt2/smt2_conv.cpp 66.08% <66.66%> (-0.03%) ⬇️
src/util/std_code_base.h 93.54% <93.54%> (ø)
...java_bytecode/create_array_with_type_intrinsic.cpp 97.67% <100.00%> (ø)
... and 31 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 8dfeb1a...eff2507. Read the comment docs.

@tautschnig tautschnig merged commit 6764a7d into diffblue:develop Oct 21, 2021
@tautschnig tautschnig deleted the empty-union branch October 21, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invariant violation in boolbv_width.cpp
3 participants