#!/usr/local/bin/rune -x # # Demonstrate array bounds checking import "sys"; import ; alias stdio.File *stdout = stdio.stdout; int main(int ac, char **av) { const char *s = "charlie"; char buf[32]; # char *ptr = s; # char *ptr = &buf[0]; char *ptr = &buf[1]; char c; # for (int i = 0; i < 33; ++i) { # stdio.show("loop", i); # c = ptr[i]; # } int x = 1; stdout->show("loop 32 should be out of bounds"); for (int i = 0; i < 33; ++i) { stdout->show("loop", i); c = *ptr; ptr = ptr + 1; ptr += x; ptr -= 1; } }