diff options
| author | 2026-10-14 18:22:04 +0330 | |
|---|---|---|
| committer | 2026-10-14 20:03:38 +0330 | |
| commit | 459b7661aaa0d65d01be064bd4b9976c4f045a5c (patch) | |
| tree | eccb0738631fc52e5116fb238c2f7f961784ff36 /tests/programs/bounds_ptr.zc | |
| parent | zy: 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_ptr.zc')
| -rw-r--r-- | tests/programs/bounds_ptr.zc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/programs/bounds_ptr.zc b/tests/programs/bounds_ptr.zc new file mode 100644 index 0000000..3190b03 --- /dev/null +++ b/tests/programs/bounds_ptr.zc @@ -0,0 +1,18 @@ +namespace; +include rt; + +// a pointer set from rt.new(n) with a constant n: a loop test i < n drops the +// check, a variable bound hoists it to the loop entry, and a body that calls +// something keeps it (the call might free the block). all three agree. +int main() { + int* p = rt.new(16); int i, s = 0, n = 16; + for (i = 0; i < 16; i++) p[i] = i; + for (i = 0; i < n; i++) s = s + p[i]; + rt.put_n(s); rt.put_c(10); + for (i = 0; i < n; i++) { s = s + p[i]; rt.put_s(""); } + rt.put_n(s); rt.put_c(10); + n = 1000; + for (i = 0; i < n; i++) s = s + p[i]; + rt.put_s("not reached\n"); + return 0; +} |
