Fix ill-typed SMT2 for flattened aggregate expressions - #9147
Open
fcasal wants to merge 1 commit into
Open
Conversation
Ignore zero-width struct components when constructing concatenations so the SMT2 back-end never emits unary concat. Classify array-valued let expressions by their emitted body and inline flattened array bindings to avoid applying array operators to bit-vectors.
fcasal
requested review from
TGWDB,
kroening,
martin-cs,
peterschrammel and
tautschnig
as code owners
August 1, 2026 10:51
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9147 +/- ##
===========================================
+ Coverage 80.83% 81.40% +0.57%
===========================================
Files 1715 1715
Lines 189989 211603 +21614
Branches 73 73
===========================================
+ Hits 153576 172264 +18688
- Misses 36413 39339 +2926 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9146.
Problem
The SMT2 aggregate encoding could emit two invalid terms:
(concat value)for a struct with several zero-width fields and only onenon-zero-width field
(select <bit-vector> index)for an array-valuedletwhose body or boundvalue is a flattened struct member
Strict SMT-LIB parsers reject these terms instead of checking the program.
The unary
concatcase is reachable from C using structs with unnamedzero-width
unsigned charbit-fields. No C producer is currently known for thearray-valued
letcase; it is covered as an internal converter invariant.Change
Struct conversion now collects the non-zero-width component indices first and
adds exactly one binary
concatper additional component. The datatypeflattening path uses the same helper.
Array-valued
letexpressions now follow the encoding of their emitted body.Bindings whose array values use the flattened bit-vector encoding are inlined;
other bindings remain in the SMT
let.Tests
unit/solvers/smt2/smt2_conv.cppnow checks:without unary
concatconcatletuses bit-vector extraction when its body is aflattened struct member
letletregression/cbmc/smt2_zero_width_struct_concatprovides a C reproducer. Itstores the struct in a union, exercising both non-datatype struct conversion
and datatype-to-bit-vector flattening.
The focused failure cases emit unary
concator applyselectto a bit-vectoron
develop. The other sections guard component order and ensure array-theorybindings are not unnecessarily inlined.
Verification
The malformed examples from the issue were also checked with Bitwuzla 0.9.1.
It rejects both original forms and accepts the corrected formulas. The bundled
CPROVER SMT2 parser rejects the array sort mismatch and accepts both corrected
forms.
The C regression passes with the default SMT2 configuration, CPROVER SMT2,
Bitwuzla, and Z3. With the old encoder, Bitwuzla reports the property as
ERRORand exits with
VERIFICATION ERROR.