aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/boundsrules.zc
blob: 1ae6a56bbb3fa6182e32131649e07cf849a6a85f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace;
include rt;

// unbounded turns the checks off: as a function prefix (in any order with
// unchecked), as a block, for one statement. o3 implies it. the last read is
// checked and stops the program.
int[8] pad;
int[4] a;

unbounded int pre(int i) { return a[i] * 0 + 1; }
unchecked unbounded int both(int i) { return a[i] * 0 + 1; }
o3 int fast(int i) { return a[i] * 0 + 1; }
int blk(int i) { int r = 0; unbounded { r = a[i] * 0 + 1; } return r; }
int one(int i) { int r = 0; unbounded r = a[i] * 0 + 1; return r; }
int checked(int i) { return a[i]; }

int main() {
	int i = 5;
	a[3] = 7;
	rt.put_n(pre(i) + both(i) + fast(i) + blk(i) + one(i)); rt.put_c(10);
	rt.put_n(checked(3)); rt.put_c(10);
	rt.put_n(checked(i)); rt.put_c(10);
	return 0;
}