From d4681529c20d5cb2630bfe09f4cf4c4ca4c98a23 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 18 Nov 2026 00:10:23 +0100 Subject: Restrict pointer subtraction by type --- testsuite/runnable/pointer_subtraction.elna | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testsuite/runnable/pointer_subtraction.elna (limited to 'testsuite/runnable/pointer_subtraction.elna') diff --git a/testsuite/runnable/pointer_subtraction.elna b/testsuite/runnable/pointer_subtraction.elna new file mode 100644 index 0000000..41d45f6 --- /dev/null +++ b/testsuite/runnable/pointer_subtraction.elna @@ -0,0 +1,18 @@ +program() +var + a: [4]Int + first: ^Int + third: ^Int + diff: Int + c: ^const Int + diff_const: Int + +begin + first := @a[1]; + third := @a[3]; + diff := third - first; + c := third; + diff_const := c - first; + assert(diff = 2); + assert(diff_const = 2) +end. -- cgit v1.2.3