aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/memdebug_interior.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:24:55 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:24:55 +0330
commit886fa9c0b7ad3c0316e85de1b2c87c54a3681b12 (patch)
treec586a0d5428cbdb019b80f5a92a8ffd80c0d962d /tests/programs/memdebug_interior.zc
parentrt.zdiv: INT_MIN / -1 is INT_MIN and % is 0 in software division too, so zc0 ... (diff)
parentmerge bounds checking (diff)
Merge branch 'main' into work/spec
Diffstat (limited to 'tests/programs/memdebug_interior.zc')
-rw-r--r--tests/programs/memdebug_interior.zc18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/programs/memdebug_interior.zc b/tests/programs/memdebug_interior.zc
new file mode 100644
index 0000000..8464f2c
--- /dev/null
+++ b/tests/programs/memdebug_interior.zc
@@ -0,0 +1,18 @@
+namespace;
+include rt;
+
+// memdebug finds the block of an interior pointer however deep it is: buf[255]
+// of a 256-word block is 255 words past its header, beyond the old 64-word scan.
+memdebug on;
+fn main() {
+ let buf = rt.new(256), small = rt.new(4);
+ buf[255] = 7;
+ buf[100] = 3;
+ small[3] = 2;
+ rt.put_n(buf[255]); rt.put_c(32);
+ rt.put_n(buf[100]); rt.put_c(32);
+ rt.put_n(small[3]); rt.put_c(10);
+ rt.free(small);
+ rt.free(buf);
+ return 0;
+}