Skip to content

Commit f134911

Browse files
GUIpspclaude
andcommitted
Add soundness-hole test: int multiplication overflow
Verifier proves _ > 0 for int c = 46341 * 46341, but the product overflows int to -2147479015. Root: int is modeled as an unbounded Z3 Int (TranslatorContextToZ3.java:93; TranslatorToZ3.java:103,327). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9106d32 commit f134911

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package testSuite;
2+
3+
import liquidjava.specification.Refinement;
4+
5+
// SOUNDNESS HOLE: Java `int` is modeled as an unbounded Z3 integer, so 32-bit
6+
// two's-complement overflow is not modeled. 46341 * 46341 == 2147488281 mathematically,
7+
// but in Java `int` it wraps to -2147479015. The verifier currently ACCEPTS "_ > 0";
8+
// at runtime the value is negative, so the refinement is violated. Should be rejected.
9+
@SuppressWarnings("unused")
10+
public class ErrorIntOverflowUnsound {
11+
public static void main(String[] args) {
12+
@Refinement("_ > 0")
13+
int c = 46341 * 46341; // Refinement Error
14+
// runtime check mirrors the refinement; aborts under -ea because c == -2147479015
15+
assert c > 0 : "c=" + c;
16+
}
17+
}

0 commit comments

Comments
 (0)