Fix flattened overflow_result_exprt field order in SMT2 - #9145
Open
fcasal wants to merge 1 commit into
Open
Conversation
Non-datatype SMT2 back-ends encoded three overflow-result paths with the value and overflow flag reversed. Emit the canonical flattened struct layout and add focused unit and regression coverage for false positives and missed overflows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fcasal
requested review from
TGWDB,
kroening,
martin-cs,
peterschrammel and
tautschnig
as code owners
August 1, 2026 08:47
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9145 +/- ##
===========================================
+ Coverage 80.83% 81.42% +0.58%
===========================================
Files 1715 1715
Lines 189989 211534 +21545
Branches 73 73
===========================================
+ Hits 153576 172236 +18660
- Misses 36413 39298 +2885 ☔ 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 #9144.
Problem
overflow_result_exprthas the struct type{ value, overflow-<kind> }.When SMT-LIB datatypes are unavailable,
smt2_convtflattens that structinto a bit-vector with
valuein the low bits and the overflow flag aboveit.
Signed add/sub and signed/unsigned multiply emitted the fields in the
opposite order. Member access then returned the wrong result and overflow
flag, causing both false counterexamples and missed overflows.
Change
The affected paths now emit:
(concat overflow_flag result)instead of:
(concat result overflow_flag)The patch updates:
Unsigned addition and subtraction were already correct: their extended
sum has the result in the low bits and the carry-out above it.
The refactoring builds the overflow predicate once and then uses it in the
datatype, flattened-result, or boolean-only output. Datatype output and
boolean-only overflow checks are unchanged.
Tests
Unit test
unit/solvers/smt2/smt2_conv.cppchecks the emitted SMT2 for:Reverting the fix makes only the four corrected sections fail. The focused
Catch run reports 4 of 22 assertions failed.
Regression tests
overflow-result-flattening1checks ten assertions across unsignedmultiply/add and signed multiply/add/sub. Before the fix, seven failed
spuriously under CPROVER SMT2 and Bitwuzla.
overflow-result-flattening2checks the opposite direction:0x10000u * 0x10000umust overflow and may truncate to zero. Before thefix, affected back-ends missed both failures.
Both tests are
CORE no-new-smt, so they exercise the default SAT,CPROVER SMT2, Bitwuzla, and Z3 paths while excluding the unsupported
incremental SMT2 back-end.
Verification
With the fix, all four tested back-ends agree:
Additional checks:
Function4failure; itpasses in isolation and with unmodified CBMC 6.8.0/6.9.0
crypto-bigintharness: Bitwuzla and Z3 agree across all40 properties after the fix
To run the focused checks: