aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/bounds_body.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 18:22:04 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 20:03:38 +0330
commit459b7661aaa0d65d01be064bd4b9976c4f045a5c (patch)
treeeccb0738631fc52e5116fb238c2f7f961784ff36 /tests/programs/bounds_body.zc
parentzy: nonzero exit on compile errors (diff)
bounds: body scan, loop-entry hoisting, pointer proofs from requested size, --explain-checks v1 (non-o3 code)
Diffstat (limited to 'tests/programs/bounds_body.zc')
-rw-r--r--tests/programs/bounds_body.zc11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/programs/bounds_body.zc b/tests/programs/bounds_body.zc
new file mode 100644
index 0000000..ea838ac
--- /dev/null
+++ b/tests/programs/bounds_body.zc
@@ -0,0 +1,11 @@
+namespace;
+include rt;
+
+// a loop proof only holds while the body leaves the index alone: here the body
+// moves i back below 0 once, so t[i] keeps its check and the access faults
+int main() {
+ int[4] t; int s = 0, once = 1;
+ for (int i = 0; i < 4; i++) { s = s + t[i]; if (once) { once = 0; i = -3000; } }
+ rt.put_n(s); rt.put_c(10);
+ return 0;
+}