aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/memdebug_interior.zc
diff options
context:
space:
mode:
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;
+}