blob: 3190b036f83a9f7aa0fa6ba1fa99bf998d1fbeb2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
}
|